#35 rest api additions for pireps
This commit is contained in:
@@ -2,13 +2,19 @@
|
||||
|
||||
namespace App\Models\Transformers;
|
||||
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
use App\Models\Flight;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
|
||||
class FlightTransformer extends TransformerAbstract
|
||||
{
|
||||
public static $aptXform = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
FlightTransformer::$aptXform = new AirportTransform();
|
||||
}
|
||||
|
||||
public function transform(Flight $flight)
|
||||
{
|
||||
$ret = [
|
||||
@@ -18,25 +24,13 @@ class FlightTransformer extends TransformerAbstract
|
||||
'code' => $flight->airline->code,
|
||||
'name' => $flight->airline->name,
|
||||
],
|
||||
'dpt' => [
|
||||
'id' => $flight->dpt_airport->id,
|
||||
'icao' => $flight->dpt_airport->icao,
|
||||
'name' => $flight->dpt_airport->name,
|
||||
],
|
||||
'arr' => [
|
||||
'id' => $flight->arr_airport->id,
|
||||
'icao' => $flight->arr_airport->icao,
|
||||
'name' => $flight->arr_airport->name,
|
||||
],
|
||||
'dpt' => FlightTransformer::$aptXform->transform($flight->dpt_airport),
|
||||
'arr' => FlightTransformer::$aptXform->transform($flight->arr_airport),
|
||||
'alt' => [],
|
||||
];
|
||||
|
||||
if($flight->alt_airport_id) {
|
||||
$flight['alt'] = [
|
||||
'id' => $flight->alt_airport->id,
|
||||
'icao' => $flight->alt_airport->icao,
|
||||
'name' => $flight->alt_airport->name,
|
||||
];
|
||||
$flight['alt'] = FlightTransformer::$aptXform->transform($flight->alt_airport);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
|
||||
Reference in New Issue
Block a user