LoginSignup
0
0

More than 3 years have passed since last update.

Laravel8 User :: createのIDを取得し、そのIDを使用して新しい行を挿入した。(メモ)

Posted at

AuthのRegisterControllerのcreateメソッドをこのように書き換えて、ユーザーの新規登録処理の直後にその登録されたユーザーの詳細データの行を挿入した。

protected function create(array $data)
    {
        $user = User::create([      //一旦、変数に入れる
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
        ]);

        userDetail::create([        //ここの処理を追加した
            'userId' => $user->id,
        ]);

        return $user;               //変数を返す
    }
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