Skip to content

Commit

Permalink
Fixed issue nabeelio#1414
Browse files Browse the repository at this point in the history
  • Loading branch information
YashGovekar committed Oct 24, 2022
1 parent 40cc827 commit a74f0c2
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions app/Services/ImportExport/FlightImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,22 @@ public function import(array $row, $index): bool
}

// Create/check that they exist
$this->processAirport($row['dpt_airport']);
$this->processAirport($row['arr_airport']);
$process_dep = $this->processAirport($row['dpt_airport']);
if (is_null($process_dep)) {
$this->log('Could not import row '.$index.'. Departure Airport not found!');
return false;
}
$process_arr = $this->processAirport($row['arr_airport']);
if (is_null($process_arr)) {
$this->log('Could not import row '.$index.'. Arrival Airport not found!');
return false;
}
if ($row['alt_airport']) {
$this->processAirport($row['alt_airport']);
$process_alt = $this->processAirport($row['alt_airport']);
if (is_null($process_alt)) {
$this->log('Could not import row '.$index.'. Alternate Airport not found!');
return false;
}
}

// Check/calculate the distance
Expand Down Expand Up @@ -198,7 +210,7 @@ protected function setDays($day_str)
*
* @return Airport
*/
protected function processAirport($airport): Airport
protected function processAirport($airport): Airport|null
{
return $this->airportSvc->lookupAirportIfNotFound($airport);
}
Expand Down

0 comments on commit a74f0c2

Please sign in to comment.