Skip to content

Commit

Permalink
Merge 4927ae6 into 7983635
Browse files Browse the repository at this point in the history
  • Loading branch information
rafinhaa committed Jun 28, 2021
2 parents 7983635 + 4927ae6 commit 5a9c390
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/authorization.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ 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. Both
parameters can be ID or name. The data return is an array.

### 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 5a9c390

Please sign in to comment.