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 Authでユーザー登録後の遷移先を分岐する。

Posted at

View

inputタグをhiddenをかける。

register_blade.php
<form method="POST" action="{{ route('register') }}" enctype="multipart/form-data">
:
<input id="name" type="hidden" name="company_register" value=1 > # 見えない要素にしておく。
:
</form>

Controller

redirectPath()メソッドを用いて、ルーティングに分岐をかける。

RegisterController.php
    // protected $redirectTo = '/';

    public function redirectPath()
    {

        if($_POST["company_register"] == 1){
            return '/company/new';
        }
            return '/';
    }

 ログイン後の遷移も同じ要領で行う。

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?