Skip to content

Commit

Permalink
Merge c61bef3 into 5690788
Browse files Browse the repository at this point in the history
  • Loading branch information
rafinhaa committed Jun 28, 2021
2 parents 5690788 + c61bef3 commit f6eb356
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/authorization.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ be either the group ID or the group's name.
$authorize->removeUserFromGroup($userId, $group_id);
$authorize->removeUserFromGroup($userId, 'moderators');

### usersInGroup()
Lists all users in a single group. The group must already exist. The only parameter is the group you want to list, which can be its ID or name. The data return is an array of user array rows.

### addPermissionToGroup()
Adds a permission to a single group. The permission must already exist. The first parameter is the permission.
The second parameter is the group to add it to. Both of the parameters can be either the ID or the name.
Expand Down
21 changes: 21 additions & 0 deletions src/Authorization/FlatAuthorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -762,4 +762,25 @@ public function groupPermissions($group)
}
}

/**
* Returns an array of all users in a group
* The group can be either the ID or the name of the group.
*
* @param int|string $group
*
* @return mixed
*/
public function usersInGroup($group)
{
if (is_numeric($group))
{
return $this->groupModel->getUsersForGroup($group);
}
else
{
$g = $this->groupModel->where('name', $group)->first();
return $this->groupModel->getUsersForGroup($g->id);
}
}

}

0 comments on commit f6eb356

Please sign in to comment.