Download the PHP package matiosfree/l-rbac without Composer
On this page you can find all versions of the php package matiosfree/l-rbac. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download matiosfree/l-rbac
More information about matiosfree/l-rbac
Files in matiosfree/l-rbac
Package l-rbac
Short Description The RBAC implementation for Laravel. Based on Laravel Abilities\Gates.
License MIT
Homepage https://github.com/matiosfree/l-rbac
Informations about the package l-rbac
l-rbac
The RBAC implementation for Laravel. Based on Laravel Abilities\Gates (v5+). This package implements a General Hierarchical RBAC, following the implementation in Yii2
Installation
- The preferred way to install this package is through composer. Either run
or add
to the require section of your composer.json.
-
Add the service provider to config/app.php.
-
Publish service provider with command:
php artisan vendor:publish --provider="MatiosFree\LRbac\RbacServiceProvider"
- Create Authorization class that extends MatiosFree\LRbac\RbacAuthorization:
NOTE! You might notice that updatePost action is part of updateOwnPost action. It means that if updatePost is not allowed the system will try to check the access to updateOwnPost as well. Because user might not have the access to update all posts, but he should be able to update his own posts. This class implements next hierarchy:
- Create specific rules for all actions you need. Your rules must implement MatiosFree\LRbac\Contracts\IRbacRuleContract:
This rule checks the user role:
This rule checks if the user is author of the post:
Usage
In the code you can check the access totally same as described in the official laravel documentation
A default role is a role that is implicitly assigned to all users. A default role is usually associated with a rule which determines if the role applies to the user being checked.
License
The MIT License (MIT). Please see License File for more information.