phpvms/app/Http/Resources/Flight.php

25 lines
625 B
PHP
Raw Normal View History

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