destroy () 里面的 $this->user () 最好加上为空判断
public function destroy()
{
$this->user()->token()->revoke();
return $this->response->noContent();
}
改成
if (!empty($this->user())) {
$this->user()->token()->revoke();
return $this->response->noContent();
} else {
return $this->response->errorUnauthorized('The token is invalid.');
}
推荐文章: