Filters & Search
A filter gives an operator or API client a named way to narrow a Resource index. The filter name is also the key used in the API query string. UI and API use the same Core query infrastructure, so define the filter once in table().
Build a status filter
use SeviaFlow\Core\Resources\Filters\SelectFilter;
use SeviaFlow\Core\Resources\Table;
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('name')->searchable(),
])
->filters([
SelectFilter::make('status')
->label('Status')
->options([
'active' => 'Active',
'paused' => 'Paused',
]),
]);
}
Here, status must match the model attribute being filtered. The same name is used by an API caller as filter[status]=active. An option's left side is the stored value; its right side is the label shown to the person using the UI.
Available filter types
| Filter | What it filters | Additional setup |
|---|---|---|
BelongsToFilter | A related Eloquent record. | Set the relationship and, when needed, a query scope and option limit. |
BooleanFilter | A true/false model value. | Use when a yes/no choice is clearer than a text search. |
DateFilter, TimeFilter | One date or time value. | Choose for exact date/time filtering. |
DateRangeFilter, DateTimeRangeFilter | A range of date or datetime values. | Use for periods such as “created between these dates”. |
NumberFilter, MoneyFilter | A numeric or money value. | Money filters can include currency metadata. |
NumberRangeFilter | A range of numeric values. | Use for values between a lower and upper bound. |
SelectFilter | One value from an allowed option list. | Declare the stored values and readable labels with options(). |
MultiSelectFilter | Several values from an allowed option list. | Declare the allowed values with options(). |
TextFilter | Text with a configured match mode. | Choose the matching behavior with mode(). |
Methods shared by filters
| Method | Meaning |
|---|---|
make('status') | Creates a filter and assigns its stable query key. |
label('Status') | Sets the name shown in the UI. If omitted, SeviaFlow derives one from the filter key. |
placeholder('Choose a status') | Sets hint text for the UI control. |
default('active') | Sets the filter's starting value. |
isActive($value) | Determines whether the supplied value represents an active filter. |
apply($query, $value) | Applies the filter value to the Eloquent query. SeviaFlow calls this as part of the index query. |
Searchable columns
Global text search only checks table columns configured as searchable. You can choose the match mode for a column:
TextColumn::make('name')->searchable();
TextColumn::make('email')->searchable(mode: 'exact');
Supported search modes are contains, starts_with, and exact. The default is configured in seviaflow.performance.search.default_mode and is starts_with by default.
Use filters from the API
Send a query parameter whose key matches the filter name. For example:
GET /api/admin/resources/customers?search=acme&sort=name&direction=asc&per_page=25&filter[status]=active
The supported index parameters are search, sort, direction, per_page, page, and filter[key]=value. The UI keeps its search, filters, sorting, page size, page, and trash scope in the browser URL. It validates list context before returning from a record page; arbitrary redirect targets are not accepted. For defaults and the complete parameter table, see CRUD and Index Queries.
Get Started