Filament Table Filters
Hi Guys,
First off, I am pretty new to Filament, absolutely loving it so far.
This might be very easy, I just dont know the solution.
I have a couple of filters on my table:
->filters([
Filter::make('Your Account')
->query(fn (Builder $query): Builder => $query->where('AGENT', Auth::user()->getAgentAccnum()))
->checkbox()
->default(),
The filter works well, But I would like the filter to be applied permanently. And the User should not be able to remove the filter. I have tried the ->hidden() approach at the end of the filter, but this seems to not apply the filter, and just hides it.
I have tried to add the where clause in getEloquentQuery() function. And that does apply it, but it then messes with my column's sorting functionality.
Is there a way to prevent the filter from being de-selected? Or is there a better place to filter the initial results?
First off, I am pretty new to Filament, absolutely loving it so far.
This might be very easy, I just dont know the solution.
I have a couple of filters on my table:
->filters([
Filter::make('Your Account')
->query(fn (Builder $query): Builder => $query->where('AGENT', Auth::user()->getAgentAccnum()))
->checkbox()
->default(),
The filter works well, But I would like the filter to be applied permanently. And the User should not be able to remove the filter. I have tried the ->hidden() approach at the end of the filter, but this seems to not apply the filter, and just hides it.
I have tried to add the where clause in getEloquentQuery() function. And that does apply it, but it then messes with my column's sorting functionality.
Is there a way to prevent the filter from being de-selected? Or is there a better place to filter the initial results?
Solution
Why a filter? I would just apply the scope to the model personally? so if you are filter the records based on a users access level you can scope the model to only ever return data where
