Skip to content

This package allow you to include relationship columns into Laravel Nova search query.

License

Notifications You must be signed in to change notification settings

TitasGailius/nova-search-relations

Folders and files

NameName
Last commit message
Last commit date
Sep 1, 2018
Sep 1, 2018
Sep 1, 2018
Sep 1, 2018
Sep 1, 2018

Repository files navigation

Search relationships in Laravel Nova

This package allow you to include relationship columns into Laravel Nova search query.

Screenshot

screenshot of the search relations tool

Installation

composer require titasgailius/search-relations

Next, add Titasgailius\SearchRelations\SearchesRelations trait to your base resource class App\Nova\Resource

use Titasgailius\SearchRelations\SearchesRelations;

abstract class Resource extends NovaResource
{
    use SearchesRelations;

Usage

Simply add public static $searchRelations array to any of your Nova resources. This array has a relationship name as a key and an array of columns to search for as a value.

/**
 * The relationship columns that should be searched.
 *
 * @var array
 */
public static $searchRelations = [
    'user' => ['username', 'email'],
];