koterle / roleable
This package is abandoned and no longer maintained.
No replacement package was suggested.
Simple role management and authorization library for Laravel.
1.1.0
2015-07-21 00:28 UTC
Requires
- php: >=5.5.9
- illuminate/support: 5.1.*
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Simple role management for Laravel by Model class and ID for Laravel 5.1
For Laravel 5.0 use the 1.0 branch. For laravel 4 use the 0.9 branch.
Install
Via Composer
{
"require": {
"koterle/roleable": "1.1.*"
}
}
Update Composer:
composer update --dev
Once it completes, add the service provideer in your config/app.php.
Koterle\Roleable\RoleableServiceProvider::class
Usage
Publish the config file and the migrations. Make sure you set your User model and User ID type correctly.
php artisan vendor:publish
Run the migrations.
php artisan migrate
Add the CanTrait to the User model:
use CanTrait;
Fill up the database with the desired roles and permissions.
Now you can use (role name/permission, class, id):
if (Auth::user()->is('administrator', 'Company', 1)) { ... } if (Auth::user()->can('manage_users', 'Company', 1)) { ... } if (Auth::user()->cannot('delete_posts', 'Blog', 1)) { ... } Auth::user()->attachRole('administrator', 'Company', 1); Auth::user()->detachRole('administrator', 'Company', 1);
License
The MIT License (MIT)