Laravel 5.4 redirection to custom url after login

前端 未结 9 2195
悲哀的现实
悲哀的现实 2020-11-28 09:46

I am using Laravel Framework 5.4.10, and I am using the regular authentication that

php artisan make:auth

provides. I want to protect the

9条回答
  •  旧时难觅i
    2020-11-28 10:11

    You should set $redirectTo value to route that you want redirect

    $this->redirectTo = route('dashboard');
    

    inside AuthController constructor.

    /**
     * Where to redirect users after login / registration.
     *
     * @var string
     */
    protected $redirectTo = '/';
    
    /**
     * Create a new authentication controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware($this->guestMiddleware(), ['except' => 'logout']);
        $this->redirectTo = route('dashboard');
    }
    

提交回复
热议问题