Download the PHP package phpexperts/laravel-rbac without Composer
On this page you can find all versions of the php package phpexperts/laravel-rbac. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download phpexperts/laravel-rbac
More information about phpexperts/laravel-rbac
Files in phpexperts/laravel-rbac
Package laravel-rbac
Short Description Role based access control for Laravel 5
License MIT
Informations about the package laravel-rbac
Laravel RBAC
Super simple RBAC/ACL implementation for Laravel 5. Laravel >=5.4 compatible fork of https://github.com/thelfensdrfer/laravel-rbac.
Installation
Require this package with composer (Packagist) using the following command
or modify your composer.json
then run composer update
.
After installation register the ServiceProvider to the providers
array in config/app.php
Run the migrations
Add RBAC middleware to your app/Http/Kernel.php
Add Rbac trait to your User
model
Usage
Roles
Create role
Assign role to user
you can also assign multiple roles at once
Revoke role from user
you can also revoke multiple roles at once
Sync roles
Any role already assigned to user will be revoked if you don't pass its id to sync method.
Permissions
Create permission
Assign permission to role
you can also assign multiple permissions at once
Revoke permission from role
you can also revoke multiple permissions at once
Sync permissions
Any permission already assigned to role will be revoked if you don't pass its id to sync method.
Check user roles/permissions
Roles and permissions can be checked on User
instance using hasRole
and canDo
methods.
Protect routes
Laravel RBAC provides middleware to protect single route and route groups. Middleware expects 2 comma separated params:
- is or can as first param - what to check (role/permission)
- role/permission slug as second param
Blade directive
Laravel RBAC provides two Blade directives to check if user has role/permission assigned.
Check for role
Check for permission
License
Laravel RBAC is open-sourced software licensed under the MIT license