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;
|
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,
|
2019-07-17 01:54:14 +08:00
|
|
|
'ident' => $this->ident,
|
2021-03-03 01:29:04 +08:00
|
|
|
'name' => $this->name_private,
|
2020-12-24 00:27:01 +08:00
|
|
|
'name_private' => $this->name_private,
|
2020-03-30 01:33:14 +08:00
|
|
|
'avatar' => $this->resolveAvatarUrl(),
|
2018-03-20 09:50:40 +08:00
|
|
|
'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,
|
2020-03-26 05:02:48 +08:00
|
|
|
'flights' => $this->flights,
|
2018-03-20 09:50:40 +08:00
|
|
|
'flight_time' => $this->flight_time,
|
2021-01-22 00:11:11 +08:00
|
|
|
'transfer_time' => $this->transfer_time,
|
2018-03-20 09:50:40 +08:00
|
|
|
'timezone' => $this->timezone,
|
|
|
|
'state' => $this->state,
|
2017-12-13 06:58:27 +08:00
|
|
|
];
|
2020-03-25 03:53:59 +08:00
|
|
|
|
2020-03-30 01:33:14 +08:00
|
|
|
$res['airline'] = Airline::make($this->whenLoaded('airline'));
|
2020-03-25 03:53:59 +08:00
|
|
|
$res['bids'] = UserBid::collection($this->whenLoaded('bids'));
|
2020-03-30 01:33:14 +08:00
|
|
|
$res['rank'] = Rank::make($this->whenLoaded('rank'));
|
2020-10-01 00:58:45 +08:00
|
|
|
$res['subfleets'] = Subfleet::make($this->whenLoaded('subfleets'));
|
2020-03-25 03:53:59 +08:00
|
|
|
|
|
|
|
return $res;
|
2017-12-13 06:58:27 +08:00
|
|
|
}
|
|
|
|
}
|