-
Install package. In console:
composer require laravelroles/rolespermissions
-
Register package middleware in app/Http/Kernel.php
protected $routeMiddleware = [
'permissions.required' => \Laravelroles\Rolespermissions\Middleware\PermissionsRequiredMiddleware::class
];
-
In console:
php artisan vendor:publish --provider="Laravelroles\Rolespermissions\RolespermissionsServiceProvider"
-
In console:
php artisan migrate
-
In console:
composer dump-autoload
-
In console:
php artisan laravelroles:seeder
-
Class User from main laravel project extends Laravelroles\Rolespermissions\Models\User
User.php:
use Laravelroles\Rolespermissions\Models\User as BaseUser;
class User extends BaseUser
{
}
-
Set localization in config/app.php - bg or en
-
Log in main program with example user test@test.bg and password test
-
Configure fine-grained access control of HRABAC for the operations show, edit and delete (for example):
Route::resource('salaries', 'SalaryController')->middleware('permissions.required:salary,show|edit|delete');