Nova searchable filter for belongsTo relationships.
sereny/nova-searchable-filter is a Laravel package for nova searchable filter for belongsto relationships..
It currently has 4 GitHub stars and 22.779 downloads on Packagist (latest version v1.0.1).
Install it with composer require sereny/nova-searchable-filter.
Discover more Laravel packages by sereny
or browse all Laravel packages to compare alternatives.
Last updated
Laravel Nova Searchable filter for belongsTo relationships.
composer require sereny/nova-searchable-filter
For this example let's assume a user belongs to a department.
To make the relationship searchable via a filter, add this to the filters() function of your Nova user resource:
You need set first and second argument, which define the filter title and the relation name.
The final argument defines the attribute name to be used in the WHERE condition.
// app/Nova/User.php
use Sereny\NovaSearchableFilter\SearchableFilter
/**
* Get the filters available for the resource.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @return array
*/
public function filters(Request $request)
{
return [
SearchableFilter::make(__('Departament'), 'department')
];
}