Posts Learn Components Snippets Categories Tags About
/

Make Laravel Nova Relation Searchable

Learn how to make Laravel Nova relation searchable to easily search for records

Created on Aug 16, 2021

16 views

To make the relationship searchable, you can chain the "searchable()" method onto the filed definition. 
BelongsTo::make('User')->searchable()
If you want to conditionally check if a field should be searchable, you can pass a closure to the searchable method.
BelongsTo::make('User')->searchable(function ($request) {
    return true;
})
Once you have defined that, you will be able to search the relation like below.
Search Relation

Snippets by

PostSrc poster

PostSrc

Full stack developer mainly focusing on the front end side of the web. The main author of PostSrc and loves writing tutorial and guides online.

Load comments for Make Laravel Nova Relation Searchable

new

PostSrc Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that's right for your project.

View Components

Other Code Snippets

More