diff --git a/app/Contracts/ImportExport.php b/app/Contracts/ImportExport.php index 9acef9a0..68ebc121 100644 --- a/app/Contracts/ImportExport.php +++ b/app/Contracts/ImportExport.php @@ -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]]; } diff --git a/app/Services/ImportExport/FlightImporter.php b/app/Services/ImportExport/FlightImporter.php index ac48409d..da5de9d1 100644 --- a/app/Services/ImportExport/FlightImporter.php +++ b/app/Services/ImportExport/FlightImporter.php @@ -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(); } } diff --git a/app/Services/ImportExport/SubfleetImporter.php b/app/Services/ImportExport/SubfleetImporter.php index c4a4ea57..20c32618 100644 --- a/app/Services/ImportExport/SubfleetImporter.php +++ b/app/Services/ImportExport/SubfleetImporter.php @@ -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(); } } }