Я пытаюсь сделать маршрутизацию к панели администратора, но необходимо указать поле администратора = 1, в противном случае перенаправить на страницу входа, я сделал промежуточное ПО IsUserAdmin и мой код в ядре:
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
],
'admin'=> [
\App\Http\Middleware\Authenticate::class,
\App\Http\Middleware\IsUserAdmin::class,
],
и промежуточное ПО:
public function handle($request, Closure $next)
{
if(Auth::user()->admin != 1)
{
$umra = package_model::where('package_type','=','1')->orderby('id','desc')->skip(0)->take(6)->get();
$tours = package_model::where('package_type','=','1')->orderby('id','desc')->skip(0)->take(5)->get();
$last_tour = package_model::where('package_type','=','2')->orderby('id','desc')->skip(0)->take(1)->get();
$last_tours = package_model::where('package_type','=','3')->orderby('id','desc')->skip(0)->take(4)->get();
$all_package = package_model::orderby('id','desc')->skip(0)->take(15)->get();
$allKey = keywords_model::orderby('id','desc')->get();
$categories = category_model::where('parent_id','=','0')->orderby('id','asc')->skip(0)->take(5)->get();
return redirect('login', ['umra'=>$umra,'tours'=>$tours,'last_tour'=>$last_tour,'last_tours'=>$last_tours,'all_package'=>$all_package,'allKey'=>$allKey,'categories'=>$categories]);
}
return $next($request);
}
и маршрут
Route::group(['middleware' => ['web','admin']], function (){
Route::get('/adminpanel', 'Admincontroller@index');
Route::get('/adminpanel/users', 'UsersController@index');
Route::get('/adminpanel/addpackage', 'Admincontroller@addnew');
}); * * 1 010
InvalidArgumentException in Response.php line 458: The HTTP status code "1" is not valid.