Fix avatar/gravatar call throwing error

This commit is contained in:
Nabeel Shahzad
2020-03-25 10:58:03 -04:00
parent eafea01e22
commit cce575c1a6
4 changed files with 17 additions and 8 deletions

View File

@@ -15,7 +15,6 @@ class User extends Resource
$res = [
'id' => $this->id,
'pilot_id' => $this->pilot_id,
'avatar' => $this->avatar->url,
'ident' => $this->ident,
'name' => $this->name,
'email' => $this->email,
@@ -26,12 +25,22 @@ class User extends Resource
'flight_time' => $this->flight_time,
'timezone' => $this->timezone,
'state' => $this->state,
'rank' => Rank::make($this->rank),
];
$res['airline'] = Airline::make($this->airline);
$res['bids'] = UserBid::collection($this->whenLoaded('bids'));
$res['flights'] = new FlightResource($this->whenLoaded('flights'));
$res['rank'] = Rank::make($this->rank);
/*
* Determine which avatar to send/use
*/
$res['avatar'] = $this->avatar;
if (empty($res['avatar'])) {
$res['avatar'] = $this->gravatar();
} else {
$res['avatar'] = $res['avatar']->url;
}
return $res;
}