Skip to content

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