diff --git a/app/Models/Account/Weather.php b/app/Models/Account/Weather.php index 37964ae79fd..80a5a923d8c 100644 --- a/app/Models/Account/Weather.php +++ b/app/Models/Account/Weather.php @@ -86,7 +86,7 @@ public function getSummaryCodeAttribute() * * @return string */ - public function getSummaryAttribute(): string + public function getSummaryAttribute(): ?string { return trans('app.weather_'.$this->summary_code); } @@ -96,7 +96,7 @@ public function getSummaryAttribute(): string * * @return string */ - public function getLocationAttribute(): string + public function getLocationAttribute(): ?string { return Arr::get($this->weather_json, 'location.name'); } @@ -106,9 +106,13 @@ public function getLocationAttribute(): string * * @return Carbon */ - public function getDateAttribute(): Carbon + public function getDateAttribute(): ?Carbon { - return Carbon::createFromTimestamp(Arr::get($this->weather_json, 'current.last_updated_epoch')); + if (($timestamp = Arr::get($this->weather_json, 'current.last_updated_epoch')) !== null) { + return Carbon::createFromTimestamp($timestamp); + } + + return null; } /**