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.

Permission Role

The bundled Permission model has easy to use methods to manage and assign roles.

attachRole($role)

Attach the given role to permission.

$permission = Permission::find(1);
 
return $permission->attachRole(Role::find(1));

attachRoleBySlug($slug)

Attach the given role slug to permission.

$permission = Permission::find(1);
 
return $permission->attachRoleBySlug('admin');

revokeRole($role)

Revoke the given permission role.

$permission = Permission::find(1);
 
return $permission->revokeRole(Role::find(1));

revokeRoleBySlug($slug)

Revoke the given permission role by slug.

$permission = Permission::find(1);
 
return $permission->revokeRoleBySlug('admin');

revokeAllRoles()

Revoke the all permission roles.

$permission = Permission::find(1);
 
return $permission->revokeAllRoles();

syncRoles($roles)

Sync permission roles.

$permission = Permission::find(1);
 
return $permission->syncRoles([1]);