From 2a03d53b3fe0dbdb432d50f3bfd0bdd3f3f18966 Mon Sep 17 00:00:00 2001 From: Nabeel S Date: Mon, 9 Mar 2020 15:06:36 -0400 Subject: [PATCH] Fix airline mapping for aircraft #628 (#633) --- app/Models/Observers/AircraftObserver.php | 7 ++++--- modules/Importer/Services/Importers/AircraftImporter.php | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Models/Observers/AircraftObserver.php b/app/Models/Observers/AircraftObserver.php index 555fc942..78cddd71 100644 --- a/app/Models/Observers/AircraftObserver.php +++ b/app/Models/Observers/AircraftObserver.php @@ -5,9 +5,6 @@ namespace App\Models\Observers; use App\Models\Aircraft; use App\Support\ICAO; -/** - * Class AircraftObserver - */ class AircraftObserver { /** @@ -17,6 +14,10 @@ class AircraftObserver */ public function creating(Aircraft $aircraft): void { + if (!empty($aircraft->airport_id)) { + $aircraft->airport_id = strtoupper($aircraft->airport_id); + } + if (empty($aircraft->hex_code)) { $aircraft->hex_code = ICAO::createHexCode(); } diff --git a/modules/Importer/Services/Importers/AircraftImporter.php b/modules/Importer/Services/Importers/AircraftImporter.php index 31ce4e13..50f7e174 100644 --- a/modules/Importer/Services/Importers/AircraftImporter.php +++ b/modules/Importer/Services/Importers/AircraftImporter.php @@ -39,7 +39,7 @@ class AircraftImporter extends BaseImporter foreach ($rows as $row) { $airline_id = null; if (!empty($row->airline)) { - $airline_id = $this->idMapper->getMapping('airlines', $row->airline_id); + $airline_id = $this->idMapper->getMapping('airlines', $row->airline); } $subfleet = $this->getSubfleet($row->icao, $airline_id);