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 |
Answered by
lonnieezell
Jan 30, 2023
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 |
0 replies
|
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(); |
1 reply
Answer selected by
ahmaruff
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bonfire has implemented this as part of a filter, but here's the relevant code which would translate to something like: