$request->except('_token');
//put this code in controller
public function logout()
{
$user = Auth::user()->token();
$user->revoke();
return response()->json('Successfully logged out');
}
//Using Laravel - Sanctum version 8, 9
// Revoke all tokens...
$user->tokens()->delete();
// Revoke the token that was used to authenticate the current request...
$request->user()->currentAccessToken()->delete();
// Revoke a specific token...
$user->tokens()->where('id', $tokenId)->delete();
public function logout() {
Auth::user()->tokens->each(function($token, $key) {
$token->delete();
});
return response()->json('Successfully logged out');
}