how to list all users based on their groups #611
-
I want query all users based on their groups. e.g list all users where $userModel = new UserModel();
$users = $userModel->where('groups', 'superadmin')->findAll();
foreach($users as $u) {
var_dump($u);
echo "<hr>";
}
die(); so how to do this? thankyou |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Group data is stored in shield/src/Database/Migrations/2020-12-28-223112_create_auth_tables.php Lines 112 to 121 in 697f570 |
Beta Was this translation helpful? Give feedback.
-
Bonfire has implemented this as part of a filter, but here's the relevant code which would translate to something like: $users = $userModel
->select('users.*)
->join('auth_groups_users agu', 'agu.user_id = users.id')
->whereIn('agu.group', 'superadmin')
->findAll(); |
Beta Was this translation helpful? Give feedback.
Bonfire has implemented this as part of a filter, but here's the relevant code which would translate to something like: