Package Data | |
---|---|
Maintainer Username: | heymowski |
Maintainer Contact: | juan@heymowski.es (Juan José Juan Heymowski) |
Package Create Date: | 2016-12-05 |
Package Last Update: | 2016-12-05 |
Home Page: | |
Language: | HTML |
License: | MIT |
Last Refreshed: | 2024-11-15 15:15:25 |
Package Statistics | |
---|---|
Total Downloads: | 50 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Another Laravel package to manage Roles and Permissions
Based on what I have learned in Laracast
Thanks to Jeffrey Way
Note:
- Tested on Laravel Framework version 5.3.26 .
- The system uses the default Laravel User model.
- You need a database connection.
composer require heymowski/laravel-roles-permissions
/*
* Package Service Providers...
*/
Heymowski\RolesAndPermissions\RolesAndPermissionsServiceProvider::class,
php artisan vendor:publish
Copied Files:
- Config File: /config/RolesAndPermissions.php
- Migrations:
2016_11_28_123904_create_roles_table
2016_11_28_124218_create_permissions_table
2016_11_28_124701_create_permission_role_table
2016_11_28_125042_create_role_user_table
- Seeds (Some roles and permissions):
RoleSeeder.php
PermissionSeeder.php
php artisan migrate
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Heymowski\RolesAndPermissions\Traits\HasRoles;
class User extends Authenticatable
{
use Notifiable, HasRoles;
To test the system you have to be logged in
http://localhost:8000/rolesandpermissions/role
@can('permission_name')
The Current User Can ...
@endcan
@cannot('permission_name')
The Current User Can't ...
@endcannot
if (Gate::allows('permission_name')) {
The current user can ...
}
if (Gate::denies('permission_name')) {
The current user can't ...
}