phpvms/app/Http/Resources/Acars.php

33 lines
653 B
PHP
Raw Normal View History

<?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.
*
2018-08-27 00:40:04 +08:00
* @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;
}
}