PHP code example of kilroyweb / roles

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

    

kilroyweb / roles example snippets


'role' => \KilroyWeb\Roles\Middleware\AuthHasRole::class,

use \KilroyWeb\Roles\Traits\HasRole;

Route::prefix('/manage')->middleware(['auth','role:admin,employee'])->group(function(){
    ...
});

if($user->roleIs('admin)){
    //user is admin role
}

if($user->roleIn(['admin','manager'])){
    //user is admin or manager role
}