login with google in laravel code example
Example 1: laravel log
use Illuminate\Support\Facades\Log;
Log::emergency($message);
Log::alert($message);
Log::critical($message);
Log::error($message);
Log::warning($message);
Log::notice($message);
Log::info($message);
Log::debug($message);
Example 2: laravel log
use Log;
Log::emergency($message);
Log::alert($message);
Log::critical($message);
Log::error($message);
Log::warning($message);
Log::notice($message);
Log::info($message);
Log::debug($message);
Example 3: login with google laravel 7
<?php namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller;use Socialite;use Auth;use Exception;use App\User; class GoogleController extends Controller{ public function redirectToGoogle() { return Socialite::driver('google')->redirect(); } public function handleGoogleCallback() { try { $user = Socialite::driver('google')->user(); $finduser = User::where('google_id', $user->id)->first(); if($finduser){ Auth::login($finduser); return redirect('/home'); }else{ $newUser = User::create([ 'name' => $user->name, 'email' => $user->email, 'google_id'=> $user->id, 'password' => encrypt('123456dummy') ]); Auth::login($newUser); return redirect('/home'); } } catch (Exception $e) { dd($e->getMessage()); } }}