Skip to content
Nav

Roles & permissions

composer require langsys/laravel-access-guard
Packagist version Monthly downloads License PHP 8.2+ Laravel 10 / 11 / 12

The bundled Role and Permission models (UUID keys, value + label) cover the vocabulary; role_has_permissions links them, and Role implements GrantsPermissions.

use Langsys\AccessGuard\Models\Role;
$admin = Role::create(['value' => 'project_admin', 'label' => 'Project Admin']);
$admin->grantPermissions(['view_projects', 'edit_projects']); // creates missing permissions
$admin->hasPermission('view_projects'); // true

Seed these from a seeder; override the models via config('access-guard.models').

Permission and role names also accept backed enums.

Feedback