Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$query = User::select([ 'users.*', DB::raw('count(roles.id) as roles_count') ])
->join('user_roles', 'users.id', '=', 'roles.user_id')
->groupBy('users.id')
->having('roles_count', '>', 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.