-
Notifications
You must be signed in to change notification settings - Fork 0
Shinobi Trait
Carlos G. Camacho O edited this page May 15, 2018
·
1 revision
The following methods will become available from your User model.
isRole($roleSlug)
can($permission)
assignRole($roleId)
revokeRole($roleId)
revokeAllRoles()
syncRoles([$roleIds])
Checks if the user is under the given role.
Auth::user()->isRole('administrator');
You may also use magic methods:
Auth::user()->isAdministrator();
Checks if the user has the given permission(s). You may pass either a string or an array of permissions to check for. In the case of an array, ALL permissions must be accountable for in order for this to return true
.
Auth::user()->can('access.admin');
or
Auth::user()->can(['access.admin', 'view.users']);
Assign the given role to the user.
Auth::user()->assignRole(1);
Revokes the given role from the user.
Auth::user()->revokeRole(1);
Revokes all roles from the user.
Auth::user()->revokeAllRoles();
Syncs the given roles with the user. This will revoke any roles not supplied.
Auth::user()->syncRoles([1, 2, 3]);