LaravelPackages.net
Acme Inc.
Toggle sidebar
khalin/nova4-searchable-belongs-to-filter

Searchable Nova 4 filter for belongsTo relationships.

74.236
4
1.0.1
About khalin/nova4-searchable-belongs-to-filter

khalin/nova4-searchable-belongs-to-filter is a Laravel package for searchable nova 4 filter for belongsto relationships.. It currently has 4 GitHub stars and 74.236 downloads on Packagist (latest version 1.0.1). Install it with composer require khalin/nova4-searchable-belongs-to-filter. Discover more Laravel packages by khalin or browse all Laravel packages to compare alternatives.

Last updated

nova-searchable-belongs-to-filter

Searchable Nova filter for belongsTo relationships.

Demo

demo

Prerequisites

This package assumes you have a text-search setup for your Eloquent models. See Laravel Scout.

Installation

composer require khalin/nova4-searchable-belongs-to-filter

Usage

For this example let's assume a user belongs to a department and a department has many users. To make the relationship searchable via a filter, add this to the filters() function of your Nova user resource:

By default the filter will display the name of the fieldAttribute you passed on instantiation. You can customize the name by passing it as an argument to the filter's construct function, for example my-new-name.

// app/Nova/User.php

use Khalin\Nova4SearchableBelongsToFilter\NovaSearchableBelongsToFilter

public function filters(Request $request)
{
    return [
	(new NovaSearchableBelongsToFilter('my-new-name'))
	    ->fieldAttribute('department')
	    ->filterBy('department_id')
    ];
}

Star History Chart