Вы собираетесь настроить логин Google.
Контроллер
public function callback(Request $request)
{
try {
$socialiteLogin = true;
$googleUser = Socialite::driver('google')->user();
$existUser = User::where('email',$googleUser->email)->first();
if($existUser) {
Auth::loginUsingId($existUser->id);
return redirect()->to('/home');
}
else {
return $request->age; // <====
if(!$request->address && !$request->country){
return redirect(route('socialite.register'));
}
$user = new User;
$user->name = $googleUser->name;
$user->email = $googleUser->email;
$user->password = md5(rand(1,10000));
$user->socialite = 1;
$user->save();
Session::put('newUser',$googleUser->name);
Event::fire(new SendMail($googleUser->email,$googleUser->name));
Auth::loginUsingId($user->id);
return redirect()->to('/home')->with('socialiteLogin',$socialiteLogin);
}
}
catch (Exception $e) {
return 'error';
}
}
Просмотр
<form action="{{ url('/redirect') }}" method="get" style="margin-top:8%;margin-bottom:8%" enctype="multipart/form-data">
@csrf
<div class="form-row">
<div class="form-group col-md-6">
<label>나이</label>
<input type="number" class="form-control" name="age" value="{{ old('age') }}" min="1" max="120"
required>
</div> <!-- form-group end.// -->
<div class="form-group col-md-6">
<label>성별</label>
<select id="inputState" class="form-control" name="gender" required>
<option selected value="남자">남자</option>
<option value="여자">여자</option>
</select>
</div> <!-- form-group end.// -->
</div> <!-- form-row.// -->
<div class="form-row">
<div class="form-group col-md-6">
<label>주거지</label>
<input type="text" class="form-control" name="address" value="{{ old('address') }}"
autocomplete=off required>
</div> <!-- form-group end.// -->
<div class="form-group col-md-6">
<label>국적</label>
<select id="inputState" class="form-control" name="country" required>
<option selected value="한국">한국</option>
<option value="일본">일본</option>
</select>
</div> <!-- form-group end.// -->
</div> <!-- form-row.// -->