2017-12-26 05:19:34 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
|
2018-05-04 04:07:16 +08:00
|
|
|
use App\Support\Units\Distance;
|
|
|
|
use App\Support\Units\Fuel;
|
2017-12-26 05:19:34 +08:00
|
|
|
use Illuminate\Http\Resources\Json\Resource;
|
|
|
|
|
|
|
|
class Acars extends Resource
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Transform the resource into an array.
|
|
|
|
*
|
2018-03-20 09:50:40 +08:00
|
|
|
* @param \Illuminate\Http\Request $request
|
2017-12-26 05:19:34 +08:00
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function toArray($request)
|
|
|
|
{
|
2018-05-04 04:07:16 +08:00
|
|
|
$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;
|
2017-12-26 05:19:34 +08:00
|
|
|
}
|
|
|
|
}
|