/** * Get the currently authenticated user. * * @return \Illuminate\Contracts\Auth\Authenticatable|null */ public function user() { if ($this->user !== null) { return $this->user; } if ($this->jwt->getToken() && $this->jwt->check()) { $id = $this->jwt->payload()->get('sub'); return $this->user = $this->provider->retrieveById($id); } }