Skip to content

Filter API

Built-in classes live in InertiaX\Components\Table\Filters and use FilterClass::make(string $key, ?string $label = null).

Filter Input Default clauses, in order
TextFilter String equals, not-equals, starts-with, not-starts-with, ends-with, not-ends-with, contains, not-contains
NumberFilter Finite number equals, not-equals, greater-than, greater-than-or-equal, less-than, less-than-or-equal, between, not-between
BooleanFilter Boolean equals, not-equals
SelectFilter Declared option value, or array with multiple() equals, not-equals
DateFilter YYYY-MM-DD equals, not-equals, between, not-between, before, after
DateTimeFilter Local YYYY-MM-DDTHH:mm[:ss[.fraction]]; space may replace T Same as date
TimeFilter HH:mm[:ss[.fraction]] Same as date

Fractions contain one to six digits. Invalid dates and reversed ranges fail. Accepted temporal strings retain their submitted form in public state; comparisons use a separately normalized value. Built-in clauses support Eloquent and collections.

is-set and is-not-set are available built-in clauses but must be added when wanted; they are not in these default sets. They require null as their no-input value.

Method Effect
key(string $key) Source field key
label(?string $label) Input label; derived from the key if omitted
type(FilterType|string $type) Built-in or namespaced input type
nullable(bool $nullable = true) Accept null input; default is false
defaultClause($clause) Choose a registered clause; otherwise the first clause is used
addClause($clause) / addClauses(array) Add new comparisons
replaceClause($clause) / replaceClauses(array) Replace existing comparisons
removeClause($clause) / removeClauses(array) Remove existing comparisons
clearClauses() / setClauses(array) Clear, or clear then add
orderClauses(Closure $callback) Reorder the clause collection

FilterType is in InertiaX\Components\Table\Filters\Enums. Clause inputs can be clause objects, ClauseType enum values, or keys. Duplicate adds and missing replace/remove targets fail. The explicit default must exist in the resulting set. See Clause API.

Explicit table filters take precedence over attached column filters and automatic filters with the same key. Automatic filters require autoFilters() and a filterable column. Number, Boolean, datetime, time, and date column classes map to their matching filters; other columns map to text. An attached filter is used without needing automatic inference.

Method Contract
options(array|Closure $options, DataSourceKind|string ...$sources) Explicit values or deferred options
multiple(bool $multiple = true) Enable multiple selection; default false
autoOptions(bool $auto = true, int $limit = 200) Discover bounded distinct values; default off; limit must be positive
supportsOptionSources(DataSourceKind|string ...$sources) Declare the kinds accepted by deferred options
addOption(string|array|Closure $value, ?string $label = null) Append an option

For exact primitive types, use explicit option records:

SelectFilter::make('level')->options([
['value' => 1, 'label' => 'Level one'],
['value' => 2, 'label' => 'Level two'],
]);

Values can be strings, numbers, or Booleans. "1", 1, and true are distinct. Multiple selection uses an array of those values. Values absent from the resolved options are rejected. Automatic option discovery sets optionsTruncated when distinct values exceed the limit; the UI displays a notice. Source-dependent option closures must declare the kinds they support.

Call booleanMap(array $map) on a BooleanFilter builder to override the stored values matching true and false. The built-in map recognizes true/false, 1/0, and strings such as yes/no, on/off, enabled/disabled, active/inactive, and checked/unchecked, plus true/false and 1/0. The submitted filter value is still a Boolean.

Basic mode accepts one root and group with direct conditions. Advanced mode accepts recursive and/or groups, bounded to eight levels including the root and 100 total condition or child-group nodes. The server rejects unsupported grouping even if submitted outside the built-in UI.

applyClauseUsing(Closure $callback, DataSourceKind|string $source, ...$additionalSources) wraps application of the selected clause. Its callback can receive $source, string $column, $value, and Closure $applyClause. Delegate with $applyClause($source, $column, $value). The selected clause still owns validation and its source requirements. See Custom filters.