phpvms/app/Http/Resources/Flight.php
2018-02-10 22:49:08 -06:00

25 lines
598 B
PHP

<?php
namespace App\Http\Resources;
use App\Support\Units\Distance;
use Illuminate\Http\Resources\Json\Resource;
class Flight extends Resource
{
public function toArray($request)
{
$flight = parent::toArray($request);
// Return multiple measures so the client can pick what they want
if($this->distance instanceof Distance) {
$flight['distance'] = $this->distance->toObject();
}
$flight['airline'] = new Airline($this->airline);
$flight['subfleets'] = Subfleet::collection($this->subfleets);
return $flight;
}
}