1//make a route as a post
2Route::post("/logout",[LogoutController::class,"store"])->name("logout");
3//and make a form in your template or what ever you frontend client..
4<form action="{{ route('logout') }}" method="post">
5 @csrf
6 <button type="submit">Logout</button>
7</form>
8//Controller will be like this.
9public function store(Request $request) {
10 auth()->logout();
11 return redirect()->route('login');
12 }
1#route
2Route::get('logout', '\App\Http\Controllers\Auth\LoginController@logout');
3
4#controller
5use Auth;
6public function logout(Request $request) {
7 Auth::logout();
8 return redirect('/login');
9}
10
11#
12
1if (!Auth::user()->isActive()) {
2 Auth::logout();
3
4 return Redirect::home();
5}
1composer require laravel/ui
2
3php artisan ui vue --auth
4
5npm install && npm run dev
1use Illuminate\Http\Request;
2use Illuminate\Support\Facades\Auth;
3
4/**
5 * Log the user out of the application.
6 *
7 * @param \Illuminate\Http\Request $request
8 * @return \Illuminate\Http\Response
9 */
10public function logout(Request $request)
11{
12 Auth::logout();
13
14 $request->session()->invalidate();
15
16 $request->session()->regenerateToken();
17
18 return redirect('/');
19}