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”.
Basic Usage
Section titled “Basic Usage”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', ])Option Formats
Section titled “Option Formats”The options() method is highly flexible and accepts arrays in various formats:
1. Associative Array
Section titled “1. Associative Array”Maps the actual database value (key) to the UI Label (value).
->options([ 1 => 'Published', 0 => 'Draft'])2. Simple List
Section titled “2. Simple List”If the value and the label are identical, you can pass a flat array.
->options(['Admin', 'Editor', 'User'])3. Formatted Array
Section titled “3. Formatted Array”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'],])Operators
Section titled “Operators”The SelectFilter automatically restricts the query operator to either is (exact match) or is_not (exclude match).
API Reference
Section titled “API Reference”| Method | Description |
|---|---|
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). |