I have a filament resource with a table. I want to change the table query based on the condition i.e. if there is a filter
->modifyQueryUsing(function (Builder $query){
if (tableFilter)
{
return $query->with('studentAcademics');
}
else
{
return $query->whereNull('id');
}
})
How can I check if there is an active table filter?
2
Answers
Use conditional clauses.
It worked in my case:
To check if there is an active table filter in Laravel Filament and modify the Eloquent query accordingly, you can use the getFilters method within the modifyQueryUsing method
getFilters: Retrieves all filters applied to the table.
isActive: Checks if a specific filter is currently active.