Properly create/update rows importing #486 (#503)

This commit is contained in:
Nabeel S
2020-01-16 10:40:42 -05:00
committed by GitHub
parent fa01c61677
commit c2f7c5e421
8 changed files with 40 additions and 33 deletions

View File

@@ -111,7 +111,7 @@ class FlightImporter extends ImportExport
// Check for a valid value
$flight_type = $row['flight_type'];
if (!array_key_exists($flight_type, FlightType::labels())) {
$flight_type = 'J';
$flight_type = FlightType::SCHED_PAX;
}
$flight->setAttribute('flight_type', $flight_type);
@@ -216,7 +216,7 @@ class FlightImporter extends ImportExport
$count = 0;
$subfleets = $this->parseMultiColumnValues($col);
foreach ($subfleets as $subfleet_type) {
$subfleet = Subfleet::firstOrCreate(
$subfleet = Subfleet::updateOrCreate(
['type' => $subfleet_type],
['name' => $subfleet_type]
);
@@ -246,7 +246,7 @@ class FlightImporter extends ImportExport
$fare_attributes = [];
}
$fare = Fare::firstOrCreate(['code' => $fare_code], ['name' => $fare_code]);
$fare = Fare::updateOrCreate(['code' => $fare_code], ['name' => $fare_code]);
$this->fareSvc->setForFlight($flight, $fare, $fare_attributes);
}
}