0
0

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 3 years have passed since last update.

【Laravel】ログインやユーザー登録を行なった後のリダイレクト先を変更したい

Posted at

ログインやユーザー登録をした後のリダイレクトを変更する方法を記載します。

使用環境

Laravel 6.2

前提

LaravelのAuth機能を使っていることを前提としています。

1,デフォルトの動き

標準のAuth機能で、ログイン、ユーザー登録をすると以下のmethodにより、
home.blade.phpが呼び出されると思います。

Auth\LoginController.php
use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = RouteServiceProvider::HOME;

2,遷移先を変える

以下のmethodを追記してあげます。

public function redirectPath()
    {
        return '/URL'; #遷移させたいURL
    }

注意

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?