Skip to content
Icon

WARNING You're browsing the documentation for an old version of LARAVEL-ACL. Consider upgrading your project to laravel-acl 10.0.

Role Permissions

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

can($permission)

Checks if the role has the given permission.

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

canAtLeast([$permission])

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']);

getPermissions()

Retrieves an array of assigned permission slugs for the role.

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

assignPermission($permissionId)

Assigns the given permission to the role.

$role = Role::find(1);
 
$role->assignPermission(1);
 
$role->save();

revokePermission($permissionId)

Revokes the given permission from the role.

$role = Role::find(1);
 
$role->revokePermission(1);
 
$role->save();

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

$role = Role::find(1);
 
$role->revokeAllPermissions();
 
$role->save();

syncPermissions([$permissionIds])

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

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