From 1161106d9c10a0d15bdda744a6b7ec01b1880b0f Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Fri, 23 Mar 2018 12:27:28 -0500 Subject: [PATCH] Fix airport field row being inserted and check against airport ID --- app/Models/Flight.php | 3 +++ app/Services/ImportExport/FlightExporter.php | 6 ++++++ app/Services/ImportExport/FlightImporter.php | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Models/Flight.php b/app/Models/Flight.php index c3fa3018..3f7325ff 100644 --- a/app/Models/Flight.php +++ b/app/Models/Flight.php @@ -20,6 +20,9 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName; * @property Collection fares * @property Collection subfleets * @property integer days + * @property string dpt_airport_id + * @property string arr_airport_id + * @property string alt_airport_id */ class Flight extends Model { diff --git a/app/Services/ImportExport/FlightExporter.php b/app/Services/ImportExport/FlightExporter.php index cb9c992c..55bce02f 100644 --- a/app/Services/ImportExport/FlightExporter.php +++ b/app/Services/ImportExport/FlightExporter.php @@ -40,6 +40,12 @@ class FlightExporter extends ImportExport $ret['airline'] = $ret['airline']->icao; $ret['distance'] = $ret['distance']->toNumber(); + $ret['dpt_airport'] = $flight->dpt_airport_id; + $ret['arr_airport'] = $flight->arr_airport_id; + if($flight->alt_airport) { + $ret['alt_airport'] = $flight->alt_airport_id; + } + $ret['days'] = $this->getDays($flight); $ret['flight_type'] = FlightType::convertToCode($ret['flight_type']); diff --git a/app/Services/ImportExport/FlightImporter.php b/app/Services/ImportExport/FlightImporter.php index d12e4dc7..49df02a2 100644 --- a/app/Services/ImportExport/FlightImporter.php +++ b/app/Services/ImportExport/FlightImporter.php @@ -169,8 +169,8 @@ class FlightImporter extends ImportExport protected function processAirport($airport) { return Airport::firstOrCreate([ - 'icao' => $airport, - ], ['name' => $airport]); + 'id' => $airport, + ], ['icao' => $airport, 'name' => $airport]); } /**