Best laravel framework open-source packages.

Authorization

Roles & Permission management with Laravel user module
Updated 10 months ago

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