kilroyweb/roles

Support for user roles

1.0.1 2017-06-28 19:07 UTC

This package is not auto-updated.

Last update: 2024-11-16 01:35:54 UTC


README

composer require kilroyweb/roles

Add to the $routeMiddleware array in app/Http/Kernel.php

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

Add the HasRole trait to your User class

use \KilroyWeb\Roles\Traits\HasRole;

Routes

Use the supplied "role" middleware to pass allowed roles

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

Available Methods

Use the roleIs and roleIn methods to check a user's role:

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

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