LoginSignup
2
1

Laravel Breeze認証 でログイン後に遷移するページをカスタマイズする

Posted at

この記事でやること

Laravel Breezeを使った認証機能で、デフォルトでは登録・ログイン後に/dashboardのパスに遷移するよう設定されていますが、それを指定のパスに遷移するようカスタマイズする方法を解説します。

動作環境

  • macOS 13.5.2
  • PHP 8.2.11
  • Laravel Framework 10.28.0
  • Laravel Breeze v1.25.0
  • laravel/sail v1.25.0
  • Composer 2.6.5

本題

登録・ログイン後にどのパスに遷移するかは、app/Providers/RouteServiceProvider.phpHOME変数で設定されています。
デフォルトでは/dashboardとなっているので、これを指定したい任意のパスに変更するだけでOKです。

RouteServiceProvider.php
public const HOME = '/home';

(上記のコードでは、/homeパスに遷移するように設定しています。)

以上です。

参考

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