how to do google login in laravel code example
Example: 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()); } }}