LoginSignup
0
0

More than 1 year has passed since last update.

Laravel ログイン機能 ログアウト後のページ変更

Posted at

laravelのログイン機能を使った場合の「ログアウト」ボタンを押した後、デフォルトで「/」に飛ぶようになっている。
これを任意のURLに飛ばすように変更する方法は以下の通り。

1.「プロジェクトフォルダ」->vender->laravel->framework->src->Illuminate->Foundation->Auth->AuthenticatesUsers.phpを開く
2.logoutメソッドを探す。
3.以下の通りに修正する。
修正前

    public function logout(Request $request)
    {
        $this->guard()->logout();

        $request->session()->invalidate();

        return $this->loggedOut($request) ?: redirect('/');
    }

修正後

    public function logout(Request $request)
    {
        $this->guard()->logout();

        $request->session()->invalidate();

        return $this->loggedOut($request) ?: redirect('/「任意のパス」');
    }
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0