At some place try:
Auth::user()->tokens()->where('id', $id)->delete();
Passing in the user id to logout should work. But don't know your setup.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
how to delete token related to SPA or Mobile in logout route? i used sanctum with this $user->currentAccessToken()->delete(); in the logout action but i got this error "Call to undefined method Laravel\Sanctum\TransientToken::delete()" i know it relates to EnsureFrontendRequestsAreStateful middleware but i want to use SPA and mobile at the same time. $user->tokens()->delete() work but it deletes all user tokens.
another question i have: can i use sanctum access token as public key for third party authentication in our API system. i want to create token for user in the admin panel and with this token user can use API of our system.
Please or to participate in this conversation.