Skip to content

Select Filter

SelectFilter renders a dropdown menu (select input) on the frontend, which is ideal for columns with a discrete set of possible values, such as “status” or “roles”.

You define a SelectFilter and pass an array of options to the options() method.

use Kinetics\Filters\SelectFilter;
SelectFilter::make('status')
->options([
'active' => 'Active',
'inactive' => 'Inactive',
'banned' => 'Banned',
])

The options() method is highly flexible and accepts arrays in various formats:

Maps the actual database value (key) to the UI Label (value).

->options([
1 => 'Published',
0 => 'Draft'
])

If the value and the label are identical, you can pass a flat array.

->options(['Admin', 'Editor', 'User'])

You can directly pass an array of objects/arrays with value and label keys, which matches the exact format TanStack uses.

->options([
['value' => 'active', 'label' => 'Active Account'],
['value' => 'banned', 'label' => 'Banned Account'],
])

The SelectFilter automatically restricts the query operator to either is (exact match) or is_not (exclude match).

MethodDescription
make(string $key)Creates a new filter instance.
label(string $label)Sets the filter label.
column(string $column)Specifies the database column name if different from the key.
relation(string $relation, string $relationKey)Explicitly sets the relationship to query.
operators(array $operators)Overrides the allowed operators for this filter.
options(array $options)Sets the options for the select dropdown (key-value pairs or array of arrays).