Anvil
Anvil - The mobile companion for Laravel Forge. Available now. Download for iOS

Filament Clickable Column Filter

  • Filament

Sometimes, you want to click a column to refine the results of a table further without going through the filter menu on a Filament table.

1// Step one: create a filter
2SelectFilter::make('user')
3 ->relationship('user', 'name')
4 ->searchable() // added so all records aren't loaded initally
5 
6// Step two: add action to column
7TextColumn::make('user.name')
8 ->label('Owner')
9 ->action(function ($livewire, $record) {
10 $livewire->tableFilters['user'] = ['value' => $record->user_id];
11 })