Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

merrant's avatar

Romanbican roles - get all users with role

Hi I'm looking for a query to get all users with certain role. Using laravel 5.2 together with romanbican/roles.

What I have tried:

$clients = User::with('roles')->where('role', 'client')->get();

$clients = User::whereHas('roles', function($q) { $q->where('name', 'client'); })->get();

And some others I cannot remember, but none of them seem to work unfortunately.

Can anyone help me with this?

0 likes
0 replies

Please or to participate in this conversation.