I am trying to create a logout function in laravel Passport.
public function logout(Request $request) {
$user = Auth::user()->token();
$user->revoke();
$tokens = $user->tokens->pluck('id');
Token::whereIn('id', $tokens)
->update(['revoked'=> true]);
RefreshToken::whereIn('access_token_id', $tokens)->update(['revoked' => true]);
}
I got this exception on postman. Is there someone who can help me for this? How can I solve this
Call to a member function revoke() on null
problem
"message": "Call to a member function revoke() on null",
"exception": "Error",
"file": "/Users/123/Desktop/Projeler/Passaport Api/App/app/Http/Controllers/ApiAuth.php",
"line": 52,