Below we’ll list all the valid that you can pass through the $attributes.
    下面我们将列出你可以通过 $attributes 传递的所有有效的 keys

    Key Required Type Description
    name true string The name of the group.
    分组名称。
    permissions false array The group permissions, pass a key/value pair.
    分组权限,传入一个 / 对数组。

    Example

    Exceptions // 异常

    Below is a list of exceptions that this method can throw.
    下面是该方法可能抛出的异常的列表。

    Example

    1. try
    2. {
    3. // Find the group using the group id
    4. // 通过 分组ID 查找分组
    5. // Update the group details
    6. // 更新分组详情
    7. $group->name = 'Users';
    8. $group->permissions = array(
    9. 'users' => 1,
    10. );
    11. // Update the group
    12. // 更新分组
    13. if ($group->save())
    14. {
    15. // Group information was updated
    16. // 分组信息已被更新
    17. }
    18. else
    19. {
    20. // Group information was not updated
    21. // 分组信息未被更新
    22. }
    23. catch (Cartalyst\Sentry\Groups\NameRequiredException $e)
    24. echo 'Name field is required';
    25. }
    26. catch (Cartalyst\Sentry\Groups\GroupExistsException $e)
    27. {
    28. echo 'Group already exists.';
    29. }
    30. catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e)
    31. {
    32. echo 'Group was not found.';
    33. }

    Exceptions

    Exception Description
    Cartalyst\Sentry\Groups\NameRequiredException If you don’t provide the group name, this exception will be thrown.
    如果你没有提供分组的名称,这个异常将被抛出。
    Cartalyst\Sentry\Groups\GroupExistsException This exception will be thrown when the group you are trying to create already exists on your database.
    当你试图创建数据库中已经存在的分组时,这个异常将被抛出。
    Cartalyst\Sentry\Groups\GroupNotFoundException If the provided group was not found, this exception will be thrown.
    如果指定的分组没有找到,这个异常将被抛出。

    Example

    Exceptions // 异常

    Below is a list of exceptions that this method can throw.
    下面是该方法可能抛出的异常的列表。

    Sentry provides simple methods to find you your groups.
    Sentry 提供了一个简单的方法来查找你的分组。

    Find all the Groups // 查找所有的分组

    1. $groups = Sentry::findAllGroups();

    Find a group by its ID // 通过“分组ID”查找一个分组

    Find a group by it’s ID.
    通过“分组ID”查找一个分组。

    Find a Group by it’s Name // 通过“分组名称”查找一个分组

    Find a group by it’s name.
    通过“分组名称”查找一个分组。

    1. try
    2. {
    3. $group = Sentry::findGroupByName('admin');
    4. }
    5. catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e)
    6. {
    7. }

    Exceptions // 异常

    Exception Description
    Cartalyst\Sentry\Groups\GroupNotFoundException If the provided group was not found, this exception will be thrown.
    如果指定的分组没有找到,这个异常将被抛出。

    getPermissions() // 返回一个分组的权限

    Returns the permissions of a group.
    返回一个分组的权限。