Download the PHP package kingmaker/filament-filter-sets without Composer
On this page you can find all versions of the php package kingmaker/filament-filter-sets. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kingmaker/filament-filter-sets
More information about kingmaker/filament-filter-sets
Files in kingmaker/filament-filter-sets
Package filament-filter-sets
Short Description Predefined filter sets for Filament tables — apply a combination of table filters in one click.
License MIT
Homepage https://github.com/kingmaker-agm/filament-filter-sets
Informations about the package filament-filter-sets
Filament Filter Sets
Predefined filter sets for Filament tables — apply a whole combination of table filters in one click, from a dropdown in the table toolbar.
A filter set is a named bundle of filter state. Instead of asking a user to open the filters panel and set four fields to find "unread quick reads", you declare that combination once and they pick it from a list.
Requirements
| Package | Filament | Laravel | PHP |
|---|---|---|---|
| 1.x | 4 or 5 | 11.28+ | 8.2+ |
Installation
The service provider is auto-discovered. There is nothing to publish and no trait to add.
Usage
Call filterSets() on the table, alongside your existing filters():
A swatch icon appears next to the table's search field. Opening it lists every set; clicking one applies it.
The FilterSet API
| Method | Description |
|---|---|
make(string $name) |
Creates the set. The name is also the identifier passed to applyTableFilterSet(). |
label(string $label) |
The text in the dropdown. Defaults to Str::headline($name) — unread_quick_reads becomes Unread Quick Reads. |
icon(string\|BackedEnum\|null $icon) |
An icon for the dropdown item. Accepts an icon name or Filament's Heroicon enum. |
color(?string $color) |
A Filament colour for the dropdown item, e.g. success. |
filters(array\|Closure $filters) |
The filter form state to apply, keyed by filter name. |
The array passed to filters() is the same shape the table's filters form uses: the outer key is
the filter name, the inner array is that filter's own form state. A filter with a single field —
like TernaryFilter — takes ['value' => ...]; a custom Filter with a schema takes one key per
field.
Runtime values
filters() also accepts a Closure, resolved every time the set is read. Use it for anything that
depends on the current request:
Applying a set programmatically
Every component with a table gains a virtual applyTableFilterSet() method, so you can trigger a
set from your own Blade or Livewire code:
Behaviour
- Sets replace, they do not merge. The filters form is reset to its defaults before a set is applied, so switching from one set to another never leaves a stray filter behind.
- State is filled through the schema, not assigned to the Livewire property, so each field's
state casts run. This is what makes a ternary
falserender as the selectedNooption rather than falling back to the placeholder. - Deferred and live filters are both supported. If the table defers its filters, the set is
applied through
applyTableFilters(); otherwise throughupdatedTableFilters(). - Unknown set names are ignored — calling
applyTableFilterSet('nope')leaves the filters exactly as they were.
Customisation
Publish the trigger view to change the icon, placement or markup:
Publish the translations to change the trigger's label, or to translate it:
Testing
Filter sets are exercised like any other Livewire call:
To run this package's own suite:
Changelog
See CHANGELOG.md.
License
The MIT License (MIT). See LICENSE.md.
All versions of filament-filter-sets with dependencies
filament/tables Version ^4.0|^5.0
illuminate/contracts Version ^11.28|^12.0|^13.0
livewire/livewire Version ^3.5|^4.0