Laravel package · MIT licence
SystemRoles: Laravel role management, simplified
SystemRoles is a role and permission package for Laravel: one role per user, a permission matrix your administrators manage on screen, and helpers to check it in your code.
composer require baberuka/systemroles
use BabeRuka\SystemRoles\Services\SystemRolesService;
public function publish(Article $article)
{
$roleId = SystemRolesService::roleIdForUser(auth()->id());
abort_unless(
SystemRolesService::roleHas($roleId, 'article.publish'),
403
);
$article->publish();
}
What you get
-
Roles
Super Admin, Admin, Manager, User, or your own. Create, edit and order them on screen.
-
Permission matrix
Every permission, such as invoice.approve, switched on or off per role from one screen.
-
One role per user, with history
Each user has exactly one role, and every role change is logged.
-
Controller access
Mark which roles may use which controllers. Controllers are scanned for you.
-
Route sync
Store every route of your app with one Artisan command and mark which roles may use it.
-
Ready-made admin area
Manage all of it at /systemroles/admin, open only to the super admin.
Read the documentation
-
Getting Started
Install SystemRoles, make yourself the super admin and run your first permission check.
-
Core Concepts
Roles, permissions, user roles, controller and route access, and how they fit together.
-
Using SystemRoles in Your App
Check permissions in code, protect routes with middleware, connect Blade, gates and policies, and customise the admin screens.
-
Reference
Admin screens, Artisan commands, the service API, package routes and the database schema.
-
Guides
Move from another role system, secure your app, fix common problems and see what is planned.