Force visible flag to true for imports #818
This commit is contained in:
@@ -3,9 +3,9 @@
|
|||||||
namespace App\Contracts;
|
namespace App\Contracts;
|
||||||
|
|
||||||
use App\Models\Airline;
|
use App\Models\Airline;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
use Log;
|
|
||||||
use Validator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common functionality used across all of the importers
|
* Common functionality used across all of the importers
|
||||||
@@ -51,9 +51,9 @@ class ImportExport
|
|||||||
*
|
*
|
||||||
* @param $code
|
* @param $code
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Database\Eloquent\Model
|
* @return Airline
|
||||||
*/
|
*/
|
||||||
public function getAirline($code)
|
public function getAirline($code): Airline
|
||||||
{
|
{
|
||||||
$airline = Airline::firstOrCreate([
|
$airline = Airline::firstOrCreate([
|
||||||
'icao' => $code,
|
'icao' => $code,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Services\ImportExport;
|
namespace App\Services\ImportExport;
|
||||||
|
|
||||||
use App\Contracts\ImportExport;
|
use App\Contracts\ImportExport;
|
||||||
|
use App\Models\Airport;
|
||||||
use App\Models\Enums\Days;
|
use App\Models\Enums\Days;
|
||||||
use App\Models\Enums\FlightType;
|
use App\Models\Enums\FlightType;
|
||||||
use App\Models\Fare;
|
use App\Models\Fare;
|
||||||
@@ -11,7 +12,7 @@ use App\Models\Subfleet;
|
|||||||
use App\Services\AirportService;
|
use App\Services\AirportService;
|
||||||
use App\Services\FareService;
|
use App\Services\FareService;
|
||||||
use App\Services\FlightService;
|
use App\Services\FlightService;
|
||||||
use Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The flight importer can be imported or export. Operates on rows
|
* 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
|
// Get the airline ID from the ICAO code
|
||||||
$airline = $this->getAirline($row['airline']);
|
$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
|
// Try to find this flight
|
||||||
|
/** @var Flight $flight */
|
||||||
$flight = Flight::firstOrNew([
|
$flight = Flight::firstOrNew([
|
||||||
'airline_id' => $airline->id,
|
'airline_id' => $airline->id,
|
||||||
'flight_number' => $row['flight_number'],
|
'flight_number' => $row['flight_number'],
|
||||||
'route_code' => $row['route_code'],
|
'route_code' => $row['route_code'],
|
||||||
'route_leg' => $row['route_leg'],
|
'route_leg' => $row['route_leg'],
|
||||||
|
'visible' => true,
|
||||||
], $row);
|
], $row);
|
||||||
|
|
||||||
$row['dpt_airport'] = strtoupper($row['dpt_airport']);
|
$row['dpt_airport'] = strtoupper($row['dpt_airport']);
|
||||||
@@ -200,9 +190,9 @@ class FlightImporter extends ImportExport
|
|||||||
*
|
*
|
||||||
* @param $airport
|
* @param $airport
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Database\Eloquent\Model
|
* @return Airport
|
||||||
*/
|
*/
|
||||||
protected function processAirport($airport)
|
protected function processAirport($airport): Airport
|
||||||
{
|
{
|
||||||
return $this->airportSvc->lookupAirportIfNotFound($airport);
|
return $this->airportSvc->lookupAirportIfNotFound($airport);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user