Step 1: Create a route
Navigate routes/web.php then put the following code below:
Route::group(['middleware' => ['auth']], function() { /** * Logout Route */ Route::get('/logout', 'LogoutController@perform')->name('logout.perform'); });
Step 2: Create a LogoutController
Navigate app/Http/Controllers directory then create a file called LogoutController.php then paste the code below:
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Session; class LogoutController extends Controller { /** * Log out account user. * * @return \Illuminate\Routing\Redirector */ public function perform() { Session::flush(); Auth::logout(); return redirect('login'); } }
0 Comments