isTokenExpired()) { return; } $this->refreshToken(); } private function refreshToken(): void { $api = app(PhantasialandApi::class); $token = $api->getAccessToken($this); $this->access_token = $token; $this->access_token_expires_at = now()->addMonths(11); $this->save(); } private function isTokenExpired(): bool { return $this?->access_token_expires_at < now(); } }