saqueib / roles-permissions-laravel

Roles and Permissions implementation on Laravel 5.4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Roles Permissions Laravel (RPL)

A stater kit with Roles and Permissions implementation on Laravel 5.4

Install

  1. To use it just clone the repo and composer install.
  2. Set the database connection
  3. To test the app run php artisan db:seed, our interactive seeder will take care of everything.

Add a new Resource

  1. Create desired resource by running
## Create Comment model with migration and resource controller
php artisan make:model Comment -mcr
  1. Register route for it.
Route::group( ['middleware' => ['auth']], function() {
    ...
    Route::resource('comments', 'CommentController');
});
  1. Now implement your controllers methods and use the Authorizable trait
use App\Authorizable;

class CommentController extends Controller
{
    use Authorizable;
    ...
  1. Now add the permissions for this new Comment model.
php artisan auth:permission Comment

That's it, you have added new resource controller which have full access control by laravel permissions.

auth:permission command

This command can be user to add or remove permission for a given model

## add permission
php artisan auth:permission Comment

## remove permissions
php artisan auth:permission Comment --remove

Author

Created by QCode.in

License

MIT license.

About

Roles and Permissions implementation on Laravel 5.4

License:MIT License


Languages

Language:PHP 71.3%Language:HTML 28.2%Language:Vue 0.4%