2017-12-13 06:58:27 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
|
2020-03-23 21:31:35 +08:00
|
|
|
use App\Contracts\Resource;
|
2020-03-25 03:53:59 +08:00
|
|
|
use App\Http\Resources\Flight as FlightResource;
|
2017-12-13 06:58:27 +08:00
|
|
|
|
2020-03-25 03:53:59 +08:00
|
|
|
/**
|
|
|
|
* @mixin \App\Models\User
|
|
|
|
*/
|
2017-12-13 06:58:27 +08:00
|
|
|
class User extends Resource
|
|
|
|
{
|
|
|
|
public function toArray($request)
|
|
|
|
{
|
2020-03-25 03:53:59 +08:00
|
|
|
$res = [
|
2018-03-20 09:50:40 +08:00
|
|
|
'id' => $this->id,
|
|
|
|
'pilot_id' => $this->pilot_id,
|
2020-03-25 03:53:59 +08:00
|
|
|
'avatar' => $this->avatar,
|
2019-07-17 01:54:14 +08:00
|
|
|
'ident' => $this->ident,
|
2018-03-20 09:50:40 +08:00
|
|
|
'name' => $this->name,
|
|
|
|
'email' => $this->email,
|
|
|
|
'rank_id' => $this->rank_id,
|
|
|
|
'home_airport' => $this->home_airport_id,
|
|
|
|
'curr_airport' => $this->curr_airport_id,
|
2017-12-13 06:58:27 +08:00
|
|
|
'last_pirep_id' => $this->last_pirep_id,
|
2018-03-20 09:50:40 +08:00
|
|
|
'flight_time' => $this->flight_time,
|
|
|
|
'timezone' => $this->timezone,
|
|
|
|
'state' => $this->state,
|
2020-03-25 03:53:59 +08:00
|
|
|
'rank' => Rank::make($this->rank),
|
2017-12-13 06:58:27 +08:00
|
|
|
];
|
2020-03-25 03:53:59 +08:00
|
|
|
|
|
|
|
$res['airline'] = Airline::make($this->airline);
|
|
|
|
$res['bids'] = UserBid::collection($this->whenLoaded('bids'));
|
|
|
|
$res['flights'] = new FlightResource($this->whenLoaded('flights'));
|
|
|
|
|
|
|
|
return $res;
|
2017-12-13 06:58:27 +08:00
|
|
|
}
|
|
|
|
}
|