Home / Snippets / Make Laravel Nova Relation Searchable
Make Laravel Nova Relation Searchable cover

Make Laravel Nova Relation Searchable

764

3 years ago

0 comments

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
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this