diff --git a/app/Services/ImportExport/FlightImporter.php b/app/Services/ImportExport/FlightImporter.php index ae1cef2c..dfcee743 100644 --- a/app/Services/ImportExport/FlightImporter.php +++ b/app/Services/ImportExport/FlightImporter.php @@ -116,13 +116,6 @@ class FlightImporter extends ImportExport $flight->setAttribute('flight_type', $flight_type); $flight->setAttribute('active', get_truth_state($row['active'])); - try { - $flight->save(); - } catch (\Exception $e) { - $this->errorLog('Error in row '.$index.': '.$e->getMessage()); - return false; - } - // Create/check that they exist $process_dep = $this->processAirport($row['dpt_airport']); if (is_null($process_dep)) { @@ -142,6 +135,13 @@ class FlightImporter extends ImportExport } } + try { + $flight->save(); + } catch (\Exception $e) { + $this->errorLog('Error in row '.$index.': '.$e->getMessage()); + return false; + } + // Check/calculate the distance if (empty($row['distance'])) { $row['distance'] = $this->airportSvc->calculateDistance(