Reputation: 77
I am currently working on a project where I am currently building the rest API. I'm making the backend part of the project in Laravel. I was just about to tokenize what I was doing with Sanctum when I saw an error in my code. I get an error on this line:
auth()->user()->tokens()->delete();
For some reason, the VS Code editor throws an error at the tokens () function, but the biggest surprise for me is that the request runs successfully. Maybe someone has any idea what the problem might be?
Here is the full logout() function:
public function logout()
{
auth()->user()->tokens()->delete();
return [
"message" => "Logged out!"
];
}
EDIT: The error message: Undefined method 'tokens'.intelephense(1013)
Upvotes: 0
Views: 1169
Reputation: 378
The problem is not with vs it is in intelephense not being able to locate the Tokens annotation try
$request->user()->tokens()->delete();
make sure your route has the Auth:sanctum middleware on
Upvotes: 3