Learn how to define searchable columns for your Nova resources.
search
property or searchableColumns
method of your resource class. This array includes the id
column by default:
$search
property has no effect on your search results and may be ignored. You should manage the searchable columns within the Algolia or Meilisearch dashboard.LIKE
clauses. However, if you are using MySQL or Postgres, you may take advantage of any full-text indexes you have defined. To do so, you should define a searchableColumns
method on your Nova resource class instead of defining a $search
property.
The searchableColumns
method should return an array of columns that are searchable. You may include an instance of Laravel\Nova\Query\Search\SearchableText
within this array to instruct Nova to utilize your full-text indexes when querying a given column:
searchableColumns
method can also include raw SQL expressions, which allow you to search through derived columns:
Post
model that is related to a User
model via an author
relatonship. You may indicate that this relationship data should be considered when searching for users by returning an instance of Laravel\Nova\Query\Search\SearchableRelation
from your resource’s searchableColumns
method.
If the searchableColumns
method does not exist on your resource, you should define it. Once the searchableColumns
method has been defined, you may remove the $search
property from your resource:
$search
property using “dot notation”:
Laravel\Nova\Query\Search\SearchableMorphToRelation
from your resource’s searchableColumns
method. The SearchableMorphToRelation
class allows you to specify which types of morphed models should be searched:
Laravel\Nova\Query\Search\SearchableJson
instance from your resource’s searchableColumns
method.
If the searchableColumns
method does not exist on your resource, you should define it. Once the searchableColumns
method has been defined, you may remove the $search
property from your resource: