Issue fixes (#413)

* Auto lookup missing airports closes #404

* Ensure flight ICAOs are capitalized closes #404

* Update htaccess in root closes #412

* Update htaccess in root closes #412

* StyleCI fix
This commit is contained in:
Nabeel S
2019-10-23 12:01:31 -04:00
committed by GitHub
parent 97baf98d04
commit 7a34756188
14 changed files with 113 additions and 24 deletions

View File

@@ -9,6 +9,7 @@ use App\Models\Enums\FlightType;
use App\Models\Fare;
use App\Models\Flight;
use App\Models\Subfleet;
use App\Services\AirportService;
use App\Services\FareService;
use App\Services\FlightService;
use Log;
@@ -47,8 +48,8 @@ class FlightImporter extends ImportExport
'fields' => 'nullable',
];
private $airportSvc;
private $fareSvc;
private $flightSvc;
/**
@@ -56,6 +57,7 @@ class FlightImporter extends ImportExport
*/
public function __construct()
{
$this->airportSvc = app(AirportService::class);
$this->fareSvc = app(FareService::class);
$this->flightSvc = app(FlightService::class);
}
@@ -94,6 +96,9 @@ class FlightImporter extends ImportExport
'route_leg' => $row['route_leg'],
], $row);
$row['dpt_airport'] = strtoupper($row['dpt_airport']);
$row['arr_airport'] = strtoupper($row['arr_airport']);
// Airport atttributes
$flight->setAttribute('days', $this->setDays($row['days']));
$flight->setAttribute('dpt_airport_id', $row['dpt_airport']);
@@ -189,9 +194,7 @@ class FlightImporter extends ImportExport
*/
protected function processAirport($airport)
{
return Airport::firstOrCreate([
'id' => $airport,
], ['icao' => $airport, 'name' => $airport]);
return $this->airportSvc->lookupAirportIfNotFound($airport);
}
/**