1. Go to this page and download the library: Download matthc/privileges 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/ */
use MatthC\Privileges\Traits\PrivilegeUserTrait;
class User extends Authenticatable
{
use PrivilegeUserTrait;
...
}
//one role
$user->hasRole('admin'); //returns true/false
//multiple roles
$user->hasRole(['admin', 'author']); //returns true if the user has one of these roles
//user must have all roles
$user->hasRole(['admin', 'author'], true);