I've never used Laravel before and I'm working on a 3 part registration using laravels default user registration & auth for step 1 of the form. Each step has its own table. The id column of step 1s table is used to link all 3 tables.
Currently im using $id = Auth::user()->id to get the logged in users id in the step 2 controller. Instead how can I route/pass the id after the user is created to step 2 controllers store method and redirect the view to step 2?
in authcontroller
protected function create(array $data)
{
return User::create([
'email' => $data['email'],
'password' => bcrypt($data['password']),
'firstName' => $data['firstName'],
'middleName' => $data['middleName'],
'lastName' => $data['lastName'],
]);
}
in Illuminate\Foundation\Auth\RegistersUsers;
public function register(Request $request)
{
$validator = $this->validator($request->all());
if ($validator->fails()) {
$this->throwValidationException(
$request, $validator
);
}
Auth::guard($this->getGuard())->login($this->create($request->all()));
// pass id to store method in profile and redirect to profileinfo
return view('user/profileinfo');
}
}