dpsoft / nova-multiselect-filter
Multiselect filter for Laravel Nova.
v1.0
2025-08-11 10:24 UTC
Requires
- laravel/nova: ^3.0
This package is not auto-updated.
Last update: 2025-08-12 08:47:52 UTC
README
This Laravel Nova package adds a multiselect to Nova's filters.
Requirements
laravel/nova: ^3.0
Features
- Multi select
- Single select
- Group select
- Search
Screenshots
Multiselect
Groupselect
Installation
Install the package in a Laravel Nova project via Composer:
composer require dpsoft/nova-multiselect-filter
Usage
The filter can be used when switching Filter
class with MultiselectFilter
.
use Dpsoft\NovaMultiselectFilter\MultiselectFilter; class BooksByAuthorFilter extends MultiselectFilter { public function apply(Request $request, $query, $value) { return $query->whereHas('books', function ($query) use ($value) { $query->whereIn('author_id', $value); }); } public function options(Request $request) { return Authors::all()->pluck('name', 'id'); } }
Built-in server-side search endpoint
use Dpsoft\NovaMultiselectFilter\MultiselectFilter; class UsersByRoleFilter extends MultiselectFilter { public function __construct() { $this->model(\App\Models\Role::class) ->searchColumn('name') ->minChars(2) ->debounce(300); } public function apply(Request $request, $query, $value) { return $query->whereIn('role_id', $value); } }
Option groups
Option groups are supported. Their syntax is the same as Laravel's option group syntax.
In this example (from Nova docs), all values are grouped by the group
key:
public function options(Request $request) { return [ 'cat' => ['label' => 'Cat', 'group' => 'Pets'], 'dog' => ['label' => 'Dog', 'group' => 'Pets'], 'eagle' => ['label' => 'Eagle', 'group' => 'Birds'], 'parrot' => ['label' => 'Parrot', 'group' => 'Birds'], ] }
Options
Possible options you can pass to the filter using the option name as a function, ie ->placeholder('Choose peanuts')
.
Option | type | default | description |
---|---|---|---|
options |
Array|callable | [] | Options in an array as key-value pairs (['id' => 'value'] ). |
placeholder |
String | Field name | The placeholder string for the input. |
max |
Number | Infinite | The maximum number of options a user can select. |
groupSelect |
Boolean | false | For use with option groups - allows the user to select whole groups at once |
singleSelect |
Boolean | false | Makes the field act as a single select which also means the saved value will not be an array. |
optionsLimit |
Number | 1000 | The maximum number of options displayed at once. Other options are still accessible through searching. |
ajaxEndpoint |
String | null | Custom endpoint to search and return options for async search. Defaults to /nova-vendor/nova-multiselect-filter/search . |
ajaxMethod |
String | get | Request method for async search. |
ajaxParam |
String | search | Query param name for the search term. |
debounce |
Number | 300 | Debounce in milliseconds for async search. |
minChars |
Number | 0 | Minimum characters before search triggers. |
model |
String | null | Fully qualified model class name used by the built-in search endpoint. |
searchColumn |
String | null | Column name used by the built-in search endpoint. |
Credits
This package was inspired by klepak/nova-multiselect-filter
License
This project is open-sourced software licensed under the MIT license.