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)
|
public function get($id)
|
||||||
{
|
{
|
||||||
$user = $this->userRepo
|
$user = $this->userRepo
|
||||||
->with(['airline', 'bids'])
|
->with(['airline', 'bids', 'rank'])
|
||||||
->find($id);
|
->find($id);
|
||||||
|
|
||||||
return new UserResource($user);
|
return new UserResource($user);
|
||||||
|
@ -15,7 +15,6 @@ class User extends Resource
|
|||||||
$res = [
|
$res = [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'pilot_id' => $this->pilot_id,
|
'pilot_id' => $this->pilot_id,
|
||||||
'avatar' => $this->avatar->url,
|
|
||||||
'ident' => $this->ident,
|
'ident' => $this->ident,
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'email' => $this->email,
|
'email' => $this->email,
|
||||||
@ -26,12 +25,22 @@ class User extends Resource
|
|||||||
'flight_time' => $this->flight_time,
|
'flight_time' => $this->flight_time,
|
||||||
'timezone' => $this->timezone,
|
'timezone' => $this->timezone,
|
||||||
'state' => $this->state,
|
'state' => $this->state,
|
||||||
'rank' => Rank::make($this->rank),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$res['airline'] = Airline::make($this->airline);
|
$res['airline'] = Airline::make($this->airline);
|
||||||
$res['bids'] = UserBid::collection($this->whenLoaded('bids'));
|
$res['bids'] = UserBid::collection($this->whenLoaded('bids'));
|
||||||
$res['flights'] = new FlightResource($this->whenLoaded('flights'));
|
$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;
|
return $res;
|
||||||
}
|
}
|
||||||
|
@ -143,9 +143,7 @@ class User extends Authenticatable
|
|||||||
public function getAvatarAttribute()
|
public function getAvatarAttribute()
|
||||||
{
|
{
|
||||||
if (!$this->attributes['avatar']) {
|
if (!$this->attributes['avatar']) {
|
||||||
return new File([
|
return null;
|
||||||
'path' => $this->gravatar(),
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new File([
|
return new File([
|
||||||
|
@ -85,9 +85,11 @@ class SimBriefTest extends TestCase
|
|||||||
|
|
||||||
$this->assertNotNull($flight['simbrief']);
|
$this->assertNotNull($flight['simbrief']);
|
||||||
$this->assertEquals($briefing->id, $flight['simbrief']['id']);
|
$this->assertEquals($briefing->id, $flight['simbrief']['id']);
|
||||||
|
|
||||||
|
$url = str_replace('http://', 'https://', $flight['simbrief']['url']);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'http://localhost/api/flights/'.$briefing->id.'/briefing',
|
'https://localhost/api/flights/'.$briefing->id.'/briefing',
|
||||||
$flight['simbrief']['url']
|
$url
|
||||||
);
|
);
|
||||||
|
|
||||||
// Retrieve the briefing via API, and then check the doctype
|
// Retrieve the briefing via API, and then check the doctype
|
||||||
|
Loading…
Reference in New Issue
Block a user