Skip to content
Icon

WARNING You're browsing the documentation for an upcoming version of Laravel Acl. The documentation and features of this release are subject to change.

Authorization

The following methods will become available from your User model once you use HasRole trait.

hasRole($roleSlug)

Check if user has the given role. A user must have at least one role order for this to return true.

auth()->user()->hasRole('administrator');

Or pass an array of roles.

auth()->user()->hasRole(['administrator', 'registered']);

can($permission)

Checks if the user has the given permission.

auth()->user()->can('users.create');

canAtLeast([$permissions])

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

auth()->user()->canAtLeast(['users.create', 'users.view']);

canAccess([$permissionOrRole])

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

auth()->user()->canAccess(['users.create', 'users.view', 'administrator']);