Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search with relationship(s) #333

Open
schubertadam opened this issue Jan 10, 2022 · 1 comment
Open

Search with relationship(s) #333

schubertadam opened this issue Jan 10, 2022 · 1 comment

Comments

@schubertadam
Copy link

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?

@schubertadam schubertadam changed the title Search with model binding Search with relationship(s) Jan 15, 2022
@danijelMarjanovic
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants