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
try
{
// Find the group using the group id
// Update the group details
$group->name = 'Users';
$group->permissions = array(
'admin' => 1,
'users' => 1,
);
// Update the group
if ($group->save())
{
// Group information was updated
}
else
{
// Group information was not updated
}
}
catch (Cartalyst\Sentry\Groups\NameRequiredException $e)
echo 'Name field is required';
}
{
echo 'Group already exists.';
}
catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e)
{
echo 'Group was not found.';
}
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
$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.
try
{
$group = Sentry::findGroupByName('admin');
}
catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e)
{
}
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.