1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Laravel(5.8)】ログアウト後の遷移先を変える

Posted at

既にいろんな記事があるのですが、それのどれもイマイチ思ったような動作をせず。

自分なりに「とりあえずこれでいいか」となったので一応備忘録がてら。

 

開発環境

【Laravel5.8】

 

やりたかったこと

ログアウトした際に指定したルーティングorリンクに飛ばしたい

内容

Laravel5.8の公式ドキュメントでログアウトを検索すると「Auth::logout()」を使え。
と書いてあるのでそれを使うために自作のコントローラーの中にメソッド作っちゃう。

↓公式
https://readouble.com/laravel/5.8/ja/authentication.html

 

ソース

public function logOut(){
       Auth::logout();
      return redirect('/'); //リダイレクトで好きなとこに飛ばす
}

とりあえずこれで問題なさそうですが、何かお気づきの点あればご指摘いただけるとありがたいです。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?