Laravel Livewire Tables Documentation

🎉 Enjoying this package? Consider sponsoring me on GitHub or buying me a beer.

This is the documentation for v3. You can switch versions in the menu at the top. Check your current version with the following command:

composer show rappasoft/laravel-livewire-tables

Select Filters

Select filters are a simple dropdown list. The user selects one choice from the list.

1use Rappasoft\LaravelLivewireTables\Views\Filters\SelectFilter;
2 
3public function filters(): array
4{
5 return [
6 SelectFilter::make('Active')
7 ->options([
8 '' => 'All',
9 'yes' => 'Yes',
10 'no' => 'No',
11 ]),
12 ];
13}

The default value

You should supply the first option as the default value. I.e. nothing selected, so the filter is not applied. This value should be an empty string. When this value is selected, the filter will be removed from the query and the query string.

Option Groups

To use <optgroup> elements, pass a nested array of options to the select filter.

1use Rappasoft\LaravelLivewireTables\Views\Filters\SelectFilter;
2 
3public function filters(): array
4{
5 return [
6 SelectFilter::make('Active')
7 ->options([
8 '' => 'All',
9 'Open' => [
10 1 => 'Type A',
11 2 => 'Type B',
12 3 => 'Type C',
13 ],
14 'Closed' => [
15 24 => 'Type X',
16 25 => 'Type Y',
17 26 => 'Type Z',
18 ],
19 ])
20 ->setFirstOption('All Tags'),
21 ];
22}

To set a default "All" option at the start of the dropdown, you can do so by utilising the

1->setFirstOption('NAME')