teamtnt / laravel-scout-tntsearch-driver

Driver for Laravel Scout search package based on https://github.com/teamtnt/tntsearch
MIT License
1.09k stars 142 forks source link

Search with relationship(s) #333

Closed schubertadam closed 1 month ago

schubertadam commented 2 years ago

Hi, is there any way to use Model::search method via with() function? I'd like to search through my User model which has Role This is my original code: User::with('roles')->paginate($this->paginate)

So my question is, how can I make it searchable?

danijelMarjanovic commented 2 years ago

Try User::search($searchPhrase)->query(function($builder) { $builder->with('roles') })->paginate($this->paginate)