How to control role's access to different path?
I am using Laravel 5.2 and Zizaco/entrust 5.2.x .
How to control role's access to different path?
For example:
The route of admin is like this:
Route::group(['middleware' => 'web'], function () {
Route::auth();
Route::group(['prefix' => 'admin','namespace' => 'Admin'], function () {
Route::resource('dashboard', 'DashboardController');
});
});
I would want that the role admin can access http://www.example.com/admin/dashboard/ ,
other roles cann't access it,
What should I do?
@sunrise Create a middleware class that checks the role and apply it to a route group:
Route::group(['middleware' => 'web'], function () {
Route::auth();
Route::group(['prefix' => 'admin', 'namespace' => 'Admin', 'middleware' => ['auth', 'admin']], function () {
Route::resource('dashboard', 'DashboardController');
});
});
Please or to participate in this conversation.