JosephSilber/bouncer

Get all users with all their roles

FunctionDJ opened this issue · 2 comments

Hi, i'd like to run a query using a JOIN from the users table over the assigned_roles and roles tables so that i can get all this information with a single query.
I feel like the docs of Bouncer only cover either getting all users of a certain role or the roles of individual users, which would be an N+1 issue.
Does Bouncer have a shortcut for this or should i just write a manual JOIN / with?

You can do it with two queries, using the standard Eloquent relationship:

User::with('roles')->get();

@JosephSilber Works nicely, thank you very much!