Делаю сайт на Laravel 5.4.
Есть роли: registered, customer-basic, customer-pro, customer-full. Для каждого создал middleware, в котором проверяется пользователь авторизован или нет и какая у него роль:
public function handle($request, Closure $next)
{
// В других middleware-файлах подставляется своя роль: 'registered', 'customer-full'...
if (Sentinel::check() && Sentinel::inRole('customer-pro'))
{
return $next($request);
}
else
{
return redirect()->back()->with(['message' => 'У вас недостаточно прав, чтобы посетить эту страницу 4']);
}
}
В роуте всё сгруппировано:
Route::group(['middleware' => ['registered']], function(){
Route::get('/success-registration', function() {
return view('frontend.auth.success');
});
Route::get('/activate/{email}/{activationCode}', [
'uses' => 'Authentication\ActivationController@activateUser',
'as' => 'activation.user'
]);
Route::group(['middleware' => ['customer-basic', 'customer-pro', 'customer-full']], function(){
Route::get('/forgot-password', [
'uses' => 'Authentication\ForgotPasswordController@index',
'as' => 'forgot.password.view',
]);
Route::post('/forgot-password', [
'uses' => 'Authentication\ForgotPasswordController@sendLink',
'as' => 'forgot.password.send',
]);
Route::get('/reset/{email}/{resetCode}', [
'uses' => 'Authentication\ForgotPasswordController@formReset',
'as' => 'forgot.password.reset.view',
]);
Route::post('/reset/{email}/{resetCode}', [
'uses' => 'Authentication\ForgotPasswordController@reset',
'as' => 'forgot.password.reset',
]);
Route::get('/price', [
'uses' => 'Backend\PriceController@index',
'as' => 'price.table.view',
]);
});
});
Мне возвращается ошибка, что у меня нет прав, чтобы посмотреть страницу, потому что я авторизован как 'registered'. Но страницу /price смотреть может и 'registered', и 'customer-basic', и 'customer-pro', и 'customer-full'. Вот что надо сделать, чтобы юзер с ОДНОЙ ИЗ ролей мог посмотреть эту страницу (ну и не только эту) ?