1. Go to this page and download the library: Download yasser/laravel-roles library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yasser / laravel-roles example snippets
'providers' => [
...
/*
* Package Service Providers...
*/
Yasser\Roles\RolesServiceProvider::class,
/*
* Application Service Providers...
*/
...
],
use Yasser\Roles\Traits\HasRolesRelations;
class User extends Authenticatable
{
use Notifiable, HasRolesRelations;
}
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
...
'verify' => \Yasser\Roles\Middlewares\VerifyPermission::class,
'check' => \Yasser\Roles\Middlewares\VerifyRole::class,
],