Laravel Nova icon Nova Packages
S

Searchable BelongsTo Filter

Readme

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')
    ];
}
Back to Top
Added 2 years ago
Last updated 3 Years Ago
Version 1.0.1
Nova Version ^4.0
Composer
khalin/nova4-searchable-belongs-to-filter
GitHub stars 5
Packagist downloads 50,553

Favorites

1 user favorited

Rating

0.00
(out of 5)
★★★★★
★★★★
★★★
★★
0 ratings

Contributors

Tags

Brought to you by Tighten

Issues/Feature Requests Stats Package Ideas