prllxtchz/authorization

Roles & Permission management with Laravel user module

v2.1.16 2018-09-14 13:29 UTC

README

687474703a2f2f706172616c6c61782e6c6b2f696d672f6c6f676f2e706e67

Latest Stable Version Total Downloads License

Adding User & User Role CRUD to Laravel Project

Installation

composer require prllxtchz/authorization

Publish Spatie\Permission package migrations & config file to project.

php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" 

running authorization package views, migrations & seeds to project.

php artisan vendor:publish --provider="Prllxtchz\Authorization\AuthorizationServiceProvider"

Then run Laravel auth command to generate auth files.

php artisan make:auth

and add HasRoles trait to User model.

use Spatie\Permission\Traits\HasRoles;

https://github.com/spatie/laravel-permission#usage

use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
{
    use HasRoles;

    // ...
}

Before run any migrations, update database/seeds/DatabaseSeeder.php file with following,

$this->call(UserPermissionSeed::class);
$this->call(UserRolePermissionSeed::class);
$this->call(GiveAllPermissionsToAdmin::class);

Then you can run all migrations with seeds.

You may need to run composer dump-autload before run migrations.

php artisan migrate --seed

Usage

Admin login detail which has all current permissions

Name: Admin
Email: admin@parallax.lk
Password: @parallax<>

Generated routes

/users /routes