middleware('guest', ['except' => 'logout']); } /** * Close the session opened by this controller. * * The trait's own version is replaced because it answers with a redirect * or a 204; this one returns nothing at all, which the framework renders * as an empty 200. Flushing the session and then rotating the CSRF token * is what stops the emptied session from being reused. */ public function logout(Request $request): void { Auth::guard('web')->logout(); $session = $request->session(); $session->invalidate(); $session->regenerateToken(); } }