Fix avatar/gravatar call throwing error
This commit is contained in:
parent
eafea01e22
commit
cce575c1a6
@ -90,7 +90,7 @@ class UserController extends Controller
|
||||
public function get($id)
|
||||
{
|
||||
$user = $this->userRepo
|
||||
->with(['airline', 'bids'])
|
||||
->with(['airline', 'bids', 'rank'])
|
||||
->find($id);
|
||||
|
||||
return new UserResource($user);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -143,9 +143,7 @@ class User extends Authenticatable
|
||||
public function getAvatarAttribute()
|
||||
{
|
||||
if (!$this->attributes['avatar']) {
|
||||
return new File([
|
||||
'path' => $this->gravatar(),
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
return new File([
|
||||
|
@ -85,9 +85,11 @@ class SimBriefTest extends TestCase
|
||||
|
||||
$this->assertNotNull($flight['simbrief']);
|
||||
$this->assertEquals($briefing->id, $flight['simbrief']['id']);
|
||||
|
||||
$url = str_replace('http://', 'https://', $flight['simbrief']['url']);
|
||||
$this->assertEquals(
|
||||
'http://localhost/api/flights/'.$briefing->id.'/briefing',
|
||||
$flight['simbrief']['url']
|
||||
'https://localhost/api/flights/'.$briefing->id.'/briefing',
|
||||
$url
|
||||
);
|
||||
|
||||
// Retrieve the briefing via API, and then check the doctype
|
||||
|
Loading…
Reference in New Issue
Block a user