🎉 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 on the left/at the top. Check your current version with the following command:
composer show rappasoft/laravel-livewire-tables
Livewire Custom Array Filter (Beta)
IN BETA This feature is currently in beta, and use in production is not recommended.
Usage
This allows you to use a child/nested Livewire Component in place of the existing Filters, giving you more control over the look/feel/behaviour of a filter. This version supports use of returning an array of values for use in filtering.
To use a LivewireComponentArrayFilter, you must include it in your namespace:
1use Rappasoft\LaravelLivewireTables\Views\Filters\LivewireComponentArrayFilter;
When creating a filter:
- Specify a unique name
- Set the path to a valid Livewire Component
- Define a filter() callback to define how the returned value will be used.
1public function filters(): array 2{ 3 return [ 4 LivewireComponentArrayFilter::make('My External Filter') 5 ->setLivewireComponent('my-test-external-filter') 6 ->filter(function (Builder $builder, array $values) { 7 $builder->whereIn('foreign_id', $values); 8 }), 9 ];10}
setPillsSeparator
As this is an array, you can define the separator to use between pills values, by default this is set to ", "
1public function filters(): array 2{ 3 return [ 4 LivewireComponentArrayFilter::make('My External Filter') 5 ->setLivewireComponent('my-test-external-filter') 6 ->setPillsSeparator(' OR ') 7 ->filter(function (Builder $builder, array $values) { 8 $builder->whereIn('foreign_id', $values); 9 }),10 ];11}