Skip to content

Role Permissions

The bundled Role model has easy to use methods to manage and assign permissions.


Checks if the role has the given permission.

$role = Role::find(1);
return $role->can('users.create');


Checks if the role has the given permission(s). At least one permission must be accounted for in order for this to return true.

$role = Role::find(1);
return $role->canAtleast(['users.create', 'users.view']);


Retrieves an array of assigned permission slugs for the role.

$role = Role::find(1);
return $role->getPermissions();

grantPermission($ids, array $attributes = [], $touch = true)

Grant the given permission to the role.

$role = Role::find(1);
$permissions = Permission::all();


Grant the given permission slug to the role.

$role = Role::find(1);
$permissions = ['create-post', 'view-post'];


Grant the given permission resource to the role.

$role = Role::find(1);
$resources = ['Users', 'Posts'];

revokePermission($id = null, $touch = true)

Revokes the given permission from the role.

$role = Role::find(1);
$role->revokePermission([1, 2]);


Revokes the given permission slug from the role.

$role = Role::find(1);


Revokes the given permission resource from the role.

$role = Role::find(1);

##revokeAllPermissions() Revokes all permissions from the role.

$role = Role::find(1);

syncPermissions($ids, $detaching = true)

Syncs the given permissions with the role. This will revoke any permissions not supplied.

$role = Role::find(1);
$role->syncPermissions([1, 2, 3]);