prllxtchz / authorization
Roles & Permission management with Laravel user module
Installs: 109
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Language:HTML
Requires
- spatie/laravel-permission: ^2.12
README
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