FilamentF
Filament3y ago
HL

Modify SelectFilter query based on another SelectFilters value (Dependent Filters)

I have these 2 filters
( in my app:

                SelectFilter::make('game')
                    ->relationship('games', 'name'),

                SelectFilter::make('server')
                    ->relationship(
                        name: 'servers',
                        titleAttribute: 'abbrevation',
                        modifyQueryUsing: function (Builder $query) {
                            return $query->orderBy('servers.game', 'asc')->orderBy('servers.id', 'asc');
                        }
                    ),


I want to make the 2nd filter so, that it only queries the servers, which are selected by the first selectFilter, or otherwise show all.
I can do that with custom filters, but is there some out of the box solution for this?
Was this page helpful?