Loxxer
Loxxer
FFilament
Created by Loxxer on 2/26/2024 in #❓┊help
How to disable scopes for related model?
Unfortunately, this does not work at all and limits the results even more. If I define a scope as you describe, the defined scope is strangely applied directly to the scope-related product models. In
Tables\Columns\ImageColumn::make('brand.icon')
->size(20)
->label('Brand')
Tables\Columns\ImageColumn::make('brand.icon')
->size(20)
->label('Brand')
the related 'Brand' model is queried. Unfortunately, the scope for the model 'Brand' is used in this query and no icons are displayed if the brand is set to 'discontinued' (the scope ensures that only brands that are 'in_service' are displayed ). I need something like modifyRelationQueryUsing():
Tables\Columns\ImageColumn::make('brand.icon')
->modifyRelationQueryUsing(fn (Builder $query) => $query->withoutGlobalScopes()) // <- here...!
->size(20)
->label('Brand')
Tables\Columns\ImageColumn::make('brand.icon')
->modifyRelationQueryUsing(fn (Builder $query) => $query->withoutGlobalScopes()) // <- here...!
->size(20)
->label('Brand')
Is there a solution for that or a quick workaround?
3 replies