phpvms/app/Http/Resources/Acars.php
2018-08-26 16:40:04 +00:00

33 lines
653 B
PHP

<?php
namespace App\Http\Resources;
use App\Support\Units\Distance;
use App\Support\Units\Fuel;
use Illuminate\Http\Resources\Json\Resource;
class Acars extends Resource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
*
* @return array
*/
public function toArray($request)
{
$obj = parent::toArray($request);
if ($this->distance instanceof Distance) {
$obj['distance'] = $this->distance->units;
}
if ($this->fuel instanceof Fuel) {
$obj['fuel'] = $this->fuel->units;
}
return $obj;
}
}