Add custom query to a filter

Tables\Filters\SelectFilter::make('causer_id')
    ->query(function (Builder $query, array $data): Builder {
        return $query->where('id', 1);
    })

When I set a filter like in the example above my table always filtered and showed only one record with ID 1. I didn't apply the filter and the query string is empty.
I want to add a custom query to a filter. How to achieve this?
Solution
query exists for the other filters like Filter and TernaryFilter. With SelectFilter, the query is handled internally for you so it acts a little differently.
Was this page helpful?