PHP code example of degecko / laravel-nova-multifilter
1. Go to this page and download the library: Download degecko/laravel-nova-multifilter library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
degecko / laravel-nova-multifilter example snippets
use DeGecko\NovaMultiFilter\MultiFilter;
public function filters(NovaRequest $request): array
{
return [
new MultiFilter('Search', [
'name' => '%w%', // LIKE search (word-boundary aware)
'email' => '%#%', // LIKE search (contains)
'status' => ['active', 'inactive'], // Select dropdown
'created_at' => ['from' => null, 'to' => null], // Date range
]),
];
}
// Flat array — values are used as both the option value and label
'status' => ['active', 'inactive', 'banned'],
// Associative — keys are stored, values are displayed
'role' => ['admin' => 'Administrator', 'editor' => 'Editor', 'user' => 'User'],
'email as E-mail' => '%#%',
'created_at as Registered' => ['from' => null, 'to' => null],
use App\Nova\Filters\StatusFilter;
use App\Nova\Filters\CategoryFilter;
new MultiFilter('Filters', [
'status' => new StatusFilter,
'category' => new CategoryFilter,
'name' => '%w%',
]),
// Scope to current tenant
new MultiFilter('Search', $columns, tap: fn($q) => $q->where('tenant_id', auth()->user()->tenant_id)),
// Include soft-deleted records
new MultiFilter('Search', $columns, tap: fn($q) => $q->withTrashed()),