Download the PHP package titasgailius/search-relations without Composer
On this page you can find all versions of the php package titasgailius/search-relations. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download titasgailius/search-relations
More information about titasgailius/search-relations
Files in titasgailius/search-relations
Informations about the package search-relations
I stand with Ukraine | πΊπ¦ |
---|
Search relationships in Laravel Nova
This package allows you to include relationship columns into Laravel Nova search query.
Screenshot
Installation
Next, add Titasgailius\SearchRelations\SearchesRelations
trait to your base resource class App\Nova\Resource
Usage
Simply add public static $searchRelations
variable to any of your Nova resources.
This array accepts a relationship name as a key and an array of searchable columns as a value.
Alternatively, you may add a static searchableRelations()
method to return an array of searchable relations.
Global search
You may customize the rules of your searchable relationships for global search by defining the $globalSearchRelations
property.
Alternatively, you may add a static globallySearchableRelations()
method to return an array of globally searchable relations.
Disabling global search for relationships
You may disable the global relationship search by declaring $globalSearchRelations
with an empty array.
Alternatevily, you may disable the global search for relationships by setting the $searchRelationsGlobally
property to false
.
Nested relationships
You may search nested relationships using dot notation.
Extending Search
You may apply custom search logic for the specified relations by retuning a class implementing a Search
interface.
Your custom search class must implement a simple Search
interface that has a single method which accepts
the current query $query
, a relationship name $relation
and a search input $search
.
You may take a look at the Titasgailius\SearchRelations\Searches\RelationSearch
class as an example.