Filter class provides simple filtering functionality for Filament tables. It creates a checkbox or toggle-based filter that can be used to filter table records.
Namespace
Inheritance
Extends:Filament\Tables\Filters\BaseFilter
Usage
The Filter class creates a simple boolean filter with a checkbox or toggle interface. Example:Methods
toggle()
Use a toggle switch instead of a checkbox.static
Returns the filter instance for method chaining.
checkbox()
Use a checkbox (default behavior).static
Returns the filter instance for method chaining.
formComponent()
Set a custom form component for the filter.string
The fully qualified class name of a field component (e.g.,
Checkbox::class or Toggle::class).static
Returns the filter instance for method chaining.
getFormField()
Get the form field component for this filter.Field
Returns the configured form field component.
getResetState()
Get the state to use when resetting the filter.array<string, mixed>
Returns an array with the reset state (typically
['isActive' => false]).Inherited Methods
The Filter class inherits methods fromBaseFilter:
make()
Create a new filter instance.string
The unique identifier for this filter.
static
Returns the filter instance.
label()
Set the filter label.string | Htmlable | Closure | null
The label to display for this filter.
static
Returns the filter instance for method chaining.
query()
Define the query modification when the filter is active.Closure | null
A callback that receives the query builder and modifies it. The callback should accept
Builder $query and optionally array $state.static
Returns the filter instance for method chaining.
default()
Set the filter as active by default.bool | Closure
default:"true"
Whether the filter should be active by default.
static
Returns the filter instance for method chaining.
indicator()
Set a custom indicator for when the filter is active.string | Indicator | Closure
The indicator text or an Indicator instance.
static
Returns the filter instance for method chaining.