OMNI Access
v1.3.0
Free
~13 min read
OMNI Access API Reference
Full API reference for user trait methods, Role, Permission and Group models, OmniAccessManager, and the CacheService.
01
Step 1 of 5
User Model Methods (via Traits)
| Method | Description | Returns |
|---|---|---|
assignRole(...$roles) |
Assign one or more roles to user | self |
removeRole(...$roles) |
Remove roles from user | self |
syncRoles(...$roles) |
Replace all user roles | self |
hasRole($role) |
Check if user has role | bool |
hasAnyRole(...$roles) |
Check if user has any of the roles | bool |
hasAllRoles(...$roles) |
Check if user has all roles | bool |
hasPermission($permission) |
Check if user has permission | bool |
hasAnyPermission(...$permissions) |
Check if user has any permission | bool |
hasAllPermissions(...$permissions) |
Check if user has all permissions | bool |
givePermissionTo(...$permissions) |
Give direct permissions to user | self |
revokePermissionTo(...$permissions) |
Revoke direct permissions | self |
getAllPermissions() |
Get all user permissions | Collection |
getCachedRoles() |
Get cached user roles | Collection |
getGroupedPermissions() |
Get permissions grouped by category | Collection |
isSuperAdmin() |
Check if user is super admin | bool |
refreshPermissionsCache() |
Refresh user's permission cache | void |
02
Step 2 of 5
Role Model Methods
| Method | Description | Returns |
|---|---|---|
givePermissionTo(...$permissions) |
Give permissions to role | self |
revokePermissionTo(...$permissions) |
Remove permissions from role | self |
syncPermissions(...$permissions) |
Sync role permissions | self |
hasPermission($permission) |
Check if role has permission | bool |
getCachedPermissions() |
Get cached role permissions | Collection |
getAllCached() |
Get all roles from cache | Collection |
findBySlugCached($slug) |
Find role by slug (cached) | ?Role |
getDefaultRole() |
Get default role | ?Role |
permissions() |
Get permissions relationship | BelongsToMany |
users() |
Get users relationship | BelongsToMany |
03
Step 3 of 5
Permission Model Methods
| Method | Description | Returns |
|---|---|---|
group() |
Get permission group | BelongsTo |
roles() |
Get roles with this permission | BelongsToMany |
getAllCached() |
Get all permissions cached | Collection |
findBySlugCached($slug) |
Find permission by slug | ?Permission |
04
Step 4 of 5
OmniAccessManager Methods
| Method | Description | Returns |
|---|---|---|
createRole($attributes) |
Create new role | Role |
createPermission($attributes) |
Create new permission | Permission |
createGroup($attributes) |
Create permission group | Group |
findRole($identifier) |
Find role by ID/slug/name | ?Role |
findPermission($identifier) |
Find permission by ID/slug | ?Permission |
findGroup($identifier) |
Find group by ID/slug | ?Group |
getAllRoles() |
Get all roles | Collection |
getAllPermissions() |
Get all permissions | Collection |
getAllGroups() |
Get all groups with permissions | Collection |
clearCache() |
Clear all RBAC cache | void |
05
Step 5 of 5
CacheService Methods
| Method | Description | Returns |
|---|---|---|
remember($key, $callback, $ttl) |
Cache with callback | mixed |
forget($key) |
Remove from cache | void |
flush() |
Clear all RBAC cache | void |
forgetUser($userId) |
Clear user cache | void |
forgetRole($roleId) |
Clear role cache | void |
forgetPermission($permissionId) |
Clear permission cache | void |
Note: All methods are fully documented with PHPDoc comments in the source code for better IDE support.
Community Discussions 0
Ask questions, share step solutions, or discuss software workflows with other professionals.
Moderated Community
Join the Community Discussion
Got stuck on a step or have a question about this configuration? Sign in to join the discussion and receive direct advice from instructors and peers.
Guide Checklist
5 Steps
Tutorial Progress
0%
No Discussions Yet
Have a question or found a clever tip for this guide? Start the conversation using the comment box above!