Download the PHP package andrey-helldar/laravel-roles without Composer
On this page you can find all versions of the php package andrey-helldar/laravel-roles. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download andrey-helldar/laravel-roles
More information about andrey-helldar/laravel-roles
Files in andrey-helldar/laravel-roles
Package laravel-roles
Short Description Simple roles and permissions handling for Laravel
License MIT
Informations about the package laravel-roles
Laravel Basic Roles and Permissions
Basic roles and permissions handling for Laravel 5.5 and up.

This package is abandoned and no longer maintained. The author suggests using the spatie/laravel-permission package instead.
Contents
- Installation
- Using
- User model
- Middleware
- Creating
- Assign, revoke and sync permissions
- Assign permissions
- Revoke permissions
- Syncing permissions
- Blade
- Checking for permissions
- A
rootrole user»roleuser»rolesuser»permissionuser»permissionsrole»permissionrole»permissions
- A
- Artisan commands
- License
Installation
If you upgrade from the old version, you can see the list of changes in the Upgrade Guide:
- Upgrading To 2.x From 1.x
To get the latest version of Laravel Roles, simply require the project using Composer:
Or manually update require block of composer.json and run composer update.
Now you can publish the configuration and migration file by running the command:
You can create the DB tables by running the migrations:
This command will create such roles, permissions, user_role and role_permission tables.
Using
User model
First, add the Helldar\Roles\Traits\HasRoles trait to your User model:
Middleware
You can add middlewares in $routeMiddleware of app/Http/Kernel.php file:
Now you can check if one of the conditions is met:
Or check the entry of all conditions:
Creating
Assign, revoke and sync permissions
This package allows for users to be associated with permissions and roles. Every role is associated with multiple permissions. A Role and a Permission are regular Eloquent models.
Assign permissions
To add roles and permissions, use the following methods:
Revoke permissions
To revoke roles and permissions, use the following methods:
Syncing permissions
To synchronization roles and permissions, use the following methods:
Blade
If you enabled the use of directives in the config file, you can still using can() blade directive with additional role() and permission() directives:
You can only use blade directives with role/permission id or slug.
Note: use @can(), @role(), @roles(), @permission() and @permissions() directives is enabling separately. See config file.
Checking for permissions
A root role:
user » role:
user » roles:
user » permission:
user » permissions:
role » permission:
role >> permissions:
Artisan commands
You can create/delete a role or a permission from a console with artisan commands:
You can also invoke the creation of roles and permissions from your application:
License
This package is released under the MIT License.
All versions of laravel-roles with dependencies
doctrine/dbal Version ^2.6
illuminate/auth Version ^5.5|^6.0|^7.0|^8.0
illuminate/cache Version ^5.5|^6.0|^7.0|^8.0
illuminate/console Version ^5.5|^6.0|^7.0|^8.0
illuminate/contracts Version ^5.5|^6.0|^7.0|^8.0
illuminate/database Version ^5.5|^6.0|^7.0|^8.0
illuminate/http Version ^5.5|^6.0|^7.0|^8.0
illuminate/support Version ^5.5|^6.0|^7.0|^8.0
symfony/http-kernel Version ^3.3|^4.0|^5.0