Skip to main content
The 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.
Example:

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.
Example:

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 from BaseFilter:

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.
Example:

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.
Example:

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.
Example:

Filter State

The Filter class manages a simple state structure:
You can access this state in the query callback:

Complete Example

Properties

$formComponent

The form component class to use for the filter input.
  • Table - Table builder
  • Column - Table columns
  • BaseFilter - Base filter class with additional functionality
  • SelectFilter - Filter with select dropdown
  • TernaryFilter - Three-state filter (yes/no/all)