I have one form in frontend where I have there is some city details , rooms details and user registration in one form like I have city name , room name , address etc email addresss and password in same form and I have done 2 logics in one controller for creating cities and registering user It is saving the both data in correct table in the database but I want that first user should register and if user is vcerified only the room details should be saved in database
I am in confusion wheather to apply if again or what
public function checkLogin(Request $request)
{
$user = User::create([
'name'=>$request->name,
'email'=>$request->email,
'password'=>$request->password,
'role_id' => config('quickadmin.default_role_id'),
]);
if ($user) {
if (Auth::check()) {
$city = TotalCity::create([
'name'=>$request->name,
'created_by'=>$request->created_by_id,
]);
}
return redirect()->to('/admin/home');
}
}
User::create()
you are creating a new user every time you callcheckLogin()
, right? Is this your expected behaviour? Maybe you should check if this user exists first (what if you're trying to save the same email twice) – sentyAuth::check()
, how aboutif ($user->email_verified_at)
? However, your logic is a bit off for acheckLogin()
method – sentyAuth::check()
is failing, that means you don't have authenticated user. Do you want the created user to be logged in at the time of creation? I believe your logic is wrong. I believe you need to useAuth\RegisterController@registered
to apply this logic entirely – senty