Filament Multi-tenancy disable automatic tenant scoping per resource

Try this on a resource page:

public static function scopeEloquentQueryToTenant(Builder $query, ?Model $tenant): Builder
{
    return $query;
}

for creation or edit. in page add this function to overide tenancy_id update

protected function handleRecordCreation(array $data): Model
    {
        $record = new ($this->getModel())($data);

        //overide here
        if ($tenant = Filament::getTenant()) {
            return $this->associateRecordWithTenant($record, $tenant);
        }

        $record->save();

        return $record;
    }

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *