From 217da07007e185f1c999c717ef634d125f0821ad Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Fri, 30 Mar 2018 20:57:30 -0500 Subject: [PATCH] Fix column headers --- app/Database/seeds/sample.yml | 3 +++ app/Models/Flight.php | 3 +++ app/Services/ExportService.php | 2 +- app/Services/ImportExport/FlightExporter.php | 2 -- tests/ImporterTest.php | 1 + 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Database/seeds/sample.yml b/app/Database/seeds/sample.yml index 407261a2..981b0f99 100644 --- a/app/Database/seeds/sample.yml +++ b/app/Database/seeds/sample.yml @@ -318,6 +318,7 @@ flights: level: 360 dpt_time: 6PM CST arr_time: 11PM EST + flight_time: 240 flight_type: J created_at: NOW updated_at: NOW @@ -329,6 +330,7 @@ flights: arr_airport_id: LGRP dpt_time: 9AM CST arr_time: 1030AM CST + flight_time: 30 flight_type: J route: PITZZ4 MNURE WLEEE4 created_at: NOW @@ -340,6 +342,7 @@ flights: route_leg: 1 dpt_airport_id: EGLL arr_airport_id: KJFK + flight_time: 480 flight_type: J dpt_time: 9AM CST arr_time: 1030AM CST diff --git a/app/Models/Flight.php b/app/Models/Flight.php index c97a7a91..293ad344 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 Airport dep_airport + * @property Airport arr_airport + * @property Airport alt_airport * @property string dpt_airport_id * @property string arr_airport_id * @property string alt_airport_id diff --git a/app/Services/ExportService.php b/app/Services/ExportService.php index 10c6e35f..bfe5d9bc 100644 --- a/app/Services/ExportService.php +++ b/app/Services/ExportService.php @@ -53,7 +53,7 @@ class ExportService extends Service $writer = $this->openCsv($path); // Write out the header first - $writer->insertOne(array_keys($exporter->getColumns())); + $writer->insertOne($exporter->getColumns()); // Write the rest of the rows foreach ($collection as $row) { diff --git a/app/Services/ImportExport/FlightExporter.php b/app/Services/ImportExport/FlightExporter.php index 04fa54dc..32635a60 100644 --- a/app/Services/ImportExport/FlightExporter.php +++ b/app/Services/ImportExport/FlightExporter.php @@ -4,7 +4,6 @@ namespace App\Services\ImportExport; use App\Interfaces\ImportExport; use App\Models\Enums\Days; -use App\Models\Enums\FlightType; use App\Models\Flight; /** @@ -47,7 +46,6 @@ class FlightExporter extends ImportExport } $ret['days'] = $this->getDays($flight); - #$ret['flight_type'] = FlightType::convertToCode($ret['flight_type']); $ret['fares'] = $this->getFares($flight); $ret['fields'] = $this->getFields($flight); diff --git a/tests/ImporterTest.php b/tests/ImporterTest.php index 46854208..2c136924 100644 --- a/tests/ImporterTest.php +++ b/tests/ImporterTest.php @@ -301,6 +301,7 @@ class ImporterTest extends TestCase $this->assertEquals('27', $exported['days']); $this->assertEquals('VMS', $exported['airline']); + $this->assertEquals($flight->flight_time, $exported['flight_time']); $this->assertEquals('J', $exported['flight_type']); $this->assertEquals('A32X;B74X', $exported['subfleets']); $this->assertEquals('Y?capacity=100;F', $exported['fares']);