PHP code example of zehirpx / laroles

1. Go to this page and download the library: Download zehirpx/laroles 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/ */

    

zehirpx / laroles example snippets




namespace App;

use zehirpx\Laroles\HasRoles;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use HasRoles;
}

$roles = new zehirpx\Laroles\RoleRepository;

$roles->create('customer-support', 'Customer Support', [
            'create-servers', 'update-servers']);

$roles->updateUserRoles($user, ['customer-support']);

$user->rolesCan('update-servers');      // true
$user->rolesCan('delete-servers');      // false

$role->can('create-servers');       // true
$role->can('delete-servers');       // false