© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
7 replies
Mikazor

Add custom query to a filter

Tables\Filters\SelectFilter::make('causer_id')
    ->query(function (Builder $query, array $data): Builder {
        return $query->where('id', 1);
    })
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
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.
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Custom Filter and Query Scope
FilamentFFilament / ❓┊help
3y ago
How to add custom sort query?
FilamentFFilament / ❓┊help
9mo ago
Applying filter to a custom page
FilamentFFilament / ❓┊help
3y ago
Checkbox - Many Many relationship custom filter query
FilamentFFilament / ❓┊help
2y ago