Download the PHP package degecko/laravel-nova-multifilter without Composer
On this page you can find all versions of the php package degecko/laravel-nova-multifilter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-nova-multifilter
Laravel Nova MultiFilter
Combine multiple filter columns into a single Nova filter panel. Supports select dropdowns, text search, date ranges, number ranges, bitwise flags, and custom filter handlers.
Installation
The service provider and assets are registered automatically via Laravel's package discovery.
Building Assets
During development:
Usage
In your Nova resource's filters() method:
Column Types
Select Dropdown
Pass an array of options. Use a flat array for value-only options, or an associative array for value => label pairs:
Text Search (LIKE)
Use a string pattern where # is replaced with the user's input:
The %w% pattern is special: it splits the input on non-alphanumeric characters and wraps each part with %, giving word-boundary-aware matching. For example, searching "John Doe" becomes %John%Doe%.
Date Range
Pass from/to keys to render two date pickers. Either bound is optional — leaving one empty creates an open-ended range:
Number Range
Add 'type' => 'range' to render number inputs instead of date pickers:
Bitwise Flags
For integer columns storing bitwise flags. Labels are auto-formatted from the keys:
Column Aliases
Prefix a column with a different display name using as:
The part before as is used for the query; the part after is displayed as the label.
Composing with Nova Filters
You can pass existing Nova filter instances directly as columns. Their options will be extracted and their apply() method will be called when the value changes:
Custom Handlers
Register custom handler callbacks for columns that need special query logic:
Defaults
Set default filter values that are applied on page load:
Query Tap
Apply a scope or constraint to all filtered queries via the tap parameter:
Debugging
Chain ->log() to output the raw SQL query to the Laravel log after filters are applied:
Full Example
How It Works
The MultiFilter renders all columns in a single horizontal filter panel. Each column type (select, text, date range, bitwise) gets the appropriate input widget. Changes are debounced (100ms) and applied as a combined filter value.
On the backend, each column's value is applied to the query based on its type:
- Arrays -
where($column, $value)or date range withwhereDate - Strings -
where($column, 'like', $pattern) - Bitwise -
whereRaw("$column & ?", [$value]) - Handlers - delegated to the callback or Nova filter's
apply()method
License
MIT