0

I am using Breeze template.I am working with User Registration. My store() user function is like below

public function store(Request $request)
    {
        $request->validate([
            'name' => 'required|string|max:255',
            'email' => 'required|string|email|max:255|unique:users',
            'password' => 'required|string|confirmed|min:8',
        ]);

        Auth::login($user = User::create([
            'name' => $request->name,
            'email' => $request->email,
            'password' => Hash::make($request->password),
        ]));

        event(new Registered($user));

        return redirect(RouteServiceProvider::HOME);
    }

I would like to save more data (like user Date of Birth) as User details in another table while Registering User. I would like to maintain one to one relationship with User table and User details table.

Actually I would like to attache something with this event(new Registered($user));. So that I can save data to another Table along with registration. How can I do that ?

Where can I get the code of this new Registered($user) ?

abu abu
  • 6,599
  • 19
  • 74
  • 131

1 Answers1

0

create a new instance

and save all other fields with id to another table

$model2 new model2();

$model->col = $request->1;
$model->fk= $user->id;
$model->save();
  • Thanks @Chaudhry Asif. Actually I would like to attache something with this event(new Registered($user));. So that I can save data to another Table along with registration. How can I do that ? – abu abu Feb 08 '21 at 15:33