What I want is to clear the value of remember_token every time I sign out.
Here's my code in User.php
public function removeToken($token) {
    $information = $this->where('remember_token', $token)->firstOrFail();
    return $information;
}
And here's my UserController.php
public function signOut(Request $request, User $user) {
   $deletedToken = $user->removeToken($request->token);
   return response()->json($deletedToken);
}
Other functions inside of User.php that has a $this is working as expected, my question is why $this keyword return an empty object whehn I want to access the removeToken()?
This line of code is working as expected, it is inside of User.php also.
public function findEmail($email) {
   return $this->where('email', $email)->firstOrFail();
}
How can I solve my problem?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire