Handle access dashboard with laravel and entrust

39 views Asked by At

I tried using entrust package and works well. I have different types of roles assign to different users. The users are have roles access to dashboard to do according to their permission. I need to make middleware on routes using entrust package to check user has last one role and permission before access the dashboard. or if there other best performance/solution to do this.

1

There are 1 answers

1
AntonyMN On

Entrust has its own middleware,

'role' => \Zizaco\Entrust\Middleware\EntrustRole::class,
'permission' => \Zizaco\Entrust\Middleware\EntrustPermission::class,
'ability' => \Zizaco\Entrust\Middleware\EntrustAbility::class,

You just need to register them in App\Http\Kernel.php. In your routes\web.php create a group with a middleware for specific users:

Route::group(['middleware'=> 'role'], function({
   Route::get('/somelink', 'SomeController@somefunction');
});