Extent select filter in Filament to show only items with all selected elements
Tobias Etzold • August 4, 2026
laravel filamentIn a web application which is utilizing Filament I came across a special use case for filtering the tags of some elements. Typically when you use the select filter with multiple entries Filament will give you every entry which has at least one of the selected tags. So when you search for A and B, you'll get all entries with the tag A, all entries with the tag B and all entries with A & B.
But in my use case I only want to filter entries which contain A & B and not the entries where only one of the selected tags was applied. So I changed the default query of my select filter.
If you use relationship(), just use options()instead and fill it with all tags. You only need the name and the id from your database. The first entry (name in this case) is the content you'll see in the dropdown list.
In query() I created a where clause for every tag selected. As a result it searches for all entries which contain all selected tags.
SelectFilter::make('tag')
->options(Tag::orderBy('name')->pluck('name', 'id'))
->query(function (Builder $query, array $data): Builder {
$tagIds = $data['values'] ?? [];
foreach ($tagIds as $tagId) {
$query->whereHas('tags', function (Builder $query) use ($tagId) {
$query->where('tags.id', $tagId);
});
}
return $query;
})
->multiple(),