From c5ab0978db74b6fa02343877a111942795d0c833 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Fri, 11 Sep 2020 09:18:27 -0400 Subject: [PATCH] Force visible flag to true for imports #818 --- app/Contracts/ImportExport.php | 8 +++---- app/Services/ImportExport/FlightImporter.php | 22 ++++++-------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/app/Contracts/ImportExport.php b/app/Contracts/ImportExport.php index 0acb60c0..b0d215ef 100644 --- a/app/Contracts/ImportExport.php +++ b/app/Contracts/ImportExport.php @@ -3,9 +3,9 @@ namespace App\Contracts; use App\Models\Airline; +use Illuminate\Support\Facades\Log; +use Illuminate\Support\Facades\Validator; use Illuminate\Validation\ValidationException; -use Log; -use Validator; /** * Common functionality used across all of the importers @@ -51,9 +51,9 @@ class ImportExport * * @param $code * - * @return \Illuminate\Database\Eloquent\Model + * @return Airline */ - public function getAirline($code) + public function getAirline($code): Airline { $airline = Airline::firstOrCreate([ 'icao' => $code, diff --git a/app/Services/ImportExport/FlightImporter.php b/app/Services/ImportExport/FlightImporter.php index 7c9653eb..d2fd6a91 100644 --- a/app/Services/ImportExport/FlightImporter.php +++ b/app/Services/ImportExport/FlightImporter.php @@ -3,6 +3,7 @@ namespace App\Services\ImportExport; use App\Contracts\ImportExport; +use App\Models\Airport; use App\Models\Enums\Days; use App\Models\Enums\FlightType; use App\Models\Fare; @@ -11,7 +12,7 @@ use App\Models\Subfleet; use App\Services\AirportService; use App\Services\FareService; use App\Services\FlightService; -use Log; +use Illuminate\Support\Facades\Log; /** * The flight importer can be imported or export. Operates on rows @@ -77,25 +78,14 @@ class FlightImporter extends ImportExport // Get the airline ID from the ICAO code $airline = $this->getAirline($row['airline']); - // Check if the imported flight is a duplicate - /*$temp_flight = new Flight([ - 'airline_id' => $airline->id, - 'flight_number' => $row['flight_number'], - 'route_code' => $row['route_code'], - 'route_leg' => $row['route_leg'], - ]); - - if($this->flightSvc->isFlightDuplicate($temp_flight)) { - $this->errorLog('Error in row '.$index.': Duplicate flight number detected'); - return false; - }*/ - // Try to find this flight + /** @var Flight $flight */ $flight = Flight::firstOrNew([ 'airline_id' => $airline->id, 'flight_number' => $row['flight_number'], 'route_code' => $row['route_code'], 'route_leg' => $row['route_leg'], + 'visible' => true, ], $row); $row['dpt_airport'] = strtoupper($row['dpt_airport']); @@ -200,9 +190,9 @@ class FlightImporter extends ImportExport * * @param $airport * - * @return \Illuminate\Database\Eloquent\Model + * @return Airport */ - protected function processAirport($airport) + protected function processAirport($airport): Airport { return $this->airportSvc->lookupAirportIfNotFound($airport); }