Skip to content

Commit

Permalink
fix: fix display empty weather (#5685)
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin authored Nov 8, 2021
1 parent 339b0fe commit 1afa06e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/Models/Account/Weather.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function getSummaryCodeAttribute()
*
* @return string
*/
public function getSummaryAttribute(): string
public function getSummaryAttribute(): ?string
{
return trans('app.weather_'.$this->summary_code);
}
Expand All @@ -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');
}
Expand All @@ -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;
}

/**
Expand Down

0 comments on commit 1afa06e

Please sign in to comment.