记住令牌在 Laravel Lumen 中不起作用
Remember Token not Working in Laravel Lumen
我想要的是在每次注销的时候清空remember_token
的值
这是我在 User.php
中的代码
public function removeToken($token) {
$information = $this->where('remember_token', $token)->firstOrFail();
return $information;
}
这是我的 UserController.php
public function signOut(Request $request, User $user) {
$deletedToken = $user->removeToken($request->token);
return response()->json($deletedToken);
}
User.php
内的其他 functions
有一个 $this
正在按预期工作,我的问题是为什么 $this
关键字 return 一个空对象 whehn我想访问 removeToken()
?
这行代码按预期工作,它也在 User.php
内部。
public function findEmail($email) {
return $this->where('email', $email)->firstOrFail();
}
我该如何解决我的问题?
此问题已通过使用 self
而不是 $this
关键字来针对 User
模型解决。
我想要的是在每次注销的时候清空remember_token
的值
这是我在 User.php
public function removeToken($token) {
$information = $this->where('remember_token', $token)->firstOrFail();
return $information;
}
这是我的 UserController.php
public function signOut(Request $request, User $user) {
$deletedToken = $user->removeToken($request->token);
return response()->json($deletedToken);
}
User.php
内的其他 functions
有一个 $this
正在按预期工作,我的问题是为什么 $this
关键字 return 一个空对象 whehn我想访问 removeToken()
?
这行代码按预期工作,它也在 User.php
内部。
public function findEmail($email) {
return $this->where('email', $email)->firstOrFail();
}
我该如何解决我的问题?
此问题已通过使用 self
而不是 $this
关键字来针对 User
模型解决。