Below we’ll list all the valid that you can pass through the $attributes.

    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. // Update the group details
    5. $group->name = 'Users';
    6. $group->permissions = array(
    7. 'admin' => 1,
    8. 'users' => 1,
    9. );
    10. // Update the group
    11. if ($group->save())
    12. {
    13. // Group information was updated
    14. }
    15. else
    16. {
    17. // Group information was not updated
    18. }
    19. }
    20. catch (Cartalyst\Sentry\Groups\NameRequiredException $e)
    21. echo 'Name field is required';
    22. }
    23. {
    24. echo 'Group already exists.';
    25. }
    26. catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e)
    27. {
    28. echo 'Group was not found.';
    29. }

    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.

    Find all the Groups

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

    Find a group by its ID

    Find a group by it’s 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.