-
How can I query the Users models that has a role using the where like?
|
Beta Was this translation helpful? Give feedback.
Answered by
montanhes
Jan 6, 2022
Replies: 2 comments
-
Oh I found an issue #985 with the solution. I was trying to search for roles on a datatable. I just added the relationship and got it to work like all others relationships:
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
montanhes
-
User::whereHas('roles', fn($query) => $query->where('name', 'like', '%'.$partialString.'%'))->get(); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh I found an issue #985 with the solution. I was trying to search for roles on a datatable.
I just added the relationship and got it to work like all others relationships:
User::with('roles')