Fix flight and subfleet import with edited fares (#1379)

* Fix fare import

* StyleFix
This commit is contained in:
B.Fatih KOZ 2022-01-11 16:17:32 +03:00 committed by GitHub
parent 09453becf8
commit 7fabd57e13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 2 deletions

View File

@ -166,6 +166,27 @@ class ImportExport
return [];
}
if (strpos($split_values[0], '?') !== false) {
// This contains the query string, which turns it into a multi-level array
$query_str = explode('?', $split_values[0]);
$parent = trim($query_str[0]);
$children = [];
$kvp = explode('&', trim($query_str[1]));
foreach ($kvp as $items) {
if (!$items) {
continue;
}
$this->kvpToArray($items, $children);
}
$ret[$parent] = $children;
return $ret;
}
// This is not a query string, return it back untouched
return [$split_values[0]];
}

View File

@ -253,8 +253,9 @@ class FlightImporter extends ImportExport
$fare_attributes = [];
}
$fare = Fare::updateOrCreate(['code' => $fare_code], ['name' => $fare_code]);
$fare = Fare::firstOrCreate(['code' => $fare_code], ['name' => $fare_code]);
$this->fareSvc->setForFlight($flight, $fare, $fare_attributes);
$fare->save();
}
}

View File

@ -84,8 +84,9 @@ class SubfleetImporter extends ImportExport
$fare_attributes = [];
}
$fare = Fare::updateOrCreate(['code' => $fare_code], ['name' => $fare_code]);
$fare = Fare::firstOrCreate(['code' => $fare_code], ['name' => $fare_code]);
$this->fareSvc->setForSubfleet($subfleet, $fare, $fare_attributes);
$fare->save();
}
}
}