1//make a route as a post and button should look like this
2 <form action="{{ route('logout') }}" method="post">
3 @csrf
4 <button type="submit">Logout</button>
5</form>
6//Controller will be like this.
7public function store(){
8 auth()->logout();
9 return redirect()->route('home');
10 }
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}