Download the PHP package mamikon/role-manager without Composer
On this page you can find all versions of the php package mamikon/role-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mamikon/role-manager
More information about mamikon/role-manager
Files in mamikon/role-manager
Package role-manager
Short Description Laravel Role And Permission Manager
License MIT
Informations about the package role-manager
RoleManager
Role and permission management system for laravel. This package impalement Role Management in Laravel. And you can create in easy way new permissions and assign them to the roles.
Install
Via Composer
Then add the ServiceProvider to the providers array in config/app.php
.
You can use the facade for shorter code. Add this to your aliases:
To publish the config settings use:
It will publish default views for Role and permission management and roleManager.php
config file.
Before starting lets go over config file and make some configurations.
Config file contain default permissions, roles.
It will create some permissions for RoleManager package, after publishing package you can add some new permissions right there and it will be more preferable than from admin panel, it will make your application more easy shippable. Each permission must contain array key, it will be name of permission, and value of that key must be an array which contain description. in addition of this you can add class and method that will make additional checking for that permission
Then You can create default roles. Each array element must contain key which will be role name, and value- that will be description of our role
Then You can assign some permissions to roles.
You can use asterisk for add all permissions to that role
Then you can add roles to users
All this configurations will be loaded after run artisan command permission:migrate
But before that we must migrate our tables. It by default will create 4 tables
- permissions
- roles
- roles_user
- permissions_roles
If in your database exist tables permissions, and roles you can change their names from config file and then migrate
RoleManager package will create routes for Role management control pages
- /
- /role(resource)
- /permission(resource)
- /user/{id}
And they will be prefixed by default with role-manager
.
By default views will be extend form layouts.app
If you don't want extend any view you can give value false
And You must give section where must be extended
All configurations except default roles, permissions and default assignments can be loaded from .env
After all configuration will done run migration
And then
Usage
RoleManager don't change any logic in laravel authorization. You can use standard laravel facades, methods and functions.
In addition RoleManager facade has 2 helper functions
RoleManager::assignRole(mixed $user, mixed $role)
RoleManager::removeRole(mixed $user, mixed $role)
As $user parameter can be User Model, or user_id(int) As $role parameter can be Role Model, role_id(int), or role name(string)
Change log
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONDUCT for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Mamikon Arakelyan
- All Contributors
License
The MIT License (MIT). Please see License File for more information.