Make sure user and acars data is sent from API
This commit is contained in:
@@ -162,13 +162,17 @@ class PirepController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pirep_id
|
||||
* @param string $id The PIREP ID
|
||||
*
|
||||
* @return PirepResource
|
||||
*/
|
||||
public function get($pirep_id)
|
||||
public function get($id)
|
||||
{
|
||||
return new PirepResource($this->pirepRepo->find($pirep_id));
|
||||
$pirep = $this->pirepRepo
|
||||
->with(['acars', 'arr_airport', 'dpt_airport', 'comments', 'flight', 'simbrief', 'user'])
|
||||
->find($id);
|
||||
|
||||
return new PirepResource($pirep);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -90,7 +90,7 @@ class UserController extends Controller
|
||||
public function get($id)
|
||||
{
|
||||
$user = $this->userRepo
|
||||
->with(['airline', 'rank'])
|
||||
->with(['airline', 'bids', 'rank'])
|
||||
->find($id);
|
||||
|
||||
return new UserResource($user);
|
||||
|
||||
@@ -27,6 +27,7 @@ class Pirep extends Resource
|
||||
{
|
||||
$res = parent::toArray($request);
|
||||
$res['ident'] = $this->ident;
|
||||
$res['status_text'] = PirepStatus::label($this->status);
|
||||
|
||||
// Set these to the response units
|
||||
if (!array_key_exists('distance', $res)) {
|
||||
@@ -62,8 +63,6 @@ class Pirep extends Resource
|
||||
$res['block_off_time'] = $this->block_off_time->toIso8601ZuluString();
|
||||
}
|
||||
|
||||
$res['status_text'] = PirepStatus::label($this->status);
|
||||
|
||||
$res['airline'] = new Airline($this->airline);
|
||||
$res['dpt_airport'] = new Airport($this->dpt_airport);
|
||||
$res['arr_airport'] = new Airport($this->arr_airport);
|
||||
@@ -73,10 +72,13 @@ class Pirep extends Resource
|
||||
$res['user'] = [
|
||||
'id' => $this->user->id,
|
||||
'name' => $this->user->name,
|
||||
'avatar' => $this->user->resolveAvatarUrl(),
|
||||
'home_airport_id' => $this->user->home_airport_id,
|
||||
'curr_airport_id' => $this->user->curr_airport_id,
|
||||
];
|
||||
|
||||
$res['flight'] = Flight::make($this->whenLoaded('flight'));
|
||||
|
||||
// format to kvp
|
||||
$res['fields'] = new PirepFieldCollection($this->fields);
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ class User extends Resource
|
||||
'ident' => $this->ident,
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
'avatar' => $this->resolveAvatarUrl(),
|
||||
'rank_id' => $this->rank_id,
|
||||
'home_airport' => $this->home_airport_id,
|
||||
'curr_airport' => $this->curr_airport_id,
|
||||
@@ -27,19 +28,9 @@ class User extends Resource
|
||||
'state' => $this->state,
|
||||
];
|
||||
|
||||
$res['airline'] = Airline::make($this->airline);
|
||||
$res['airline'] = Airline::make($this->whenLoaded('airline'));
|
||||
$res['bids'] = UserBid::collection($this->whenLoaded('bids'));
|
||||
$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;
|
||||
}
|
||||
$res['rank'] = Rank::make($this->whenLoaded('rank'));
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user