Filament Clickable Column Filter

Submitted by techenby - 3 months ago

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.

// Step one: create a filter
    ->relationship('user', 'name')
    ->searchable() // added so all records aren't loaded initally
// Step two: add action to column
    ->action(function ($livewire, $record) {
        $livewire->tableFilters['user'] = ['value' => $record->user_id];