Fix error in flight importer

This commit is contained in:
Nabeel Shahzad
2018-03-29 11:47:37 -05:00
parent 184123194b
commit 0bf1286c3a
3 changed files with 9 additions and 4 deletions

View File

@@ -62,7 +62,6 @@ class Flight extends Model
'level' => 'integer',
'distance' => 'float',
'flight_time' => 'integer',
'flight_type' => 'integer',
'has_bid' => 'boolean',
'active' => 'boolean',
];

View File

@@ -92,8 +92,14 @@ class FlightImporter extends ImportExport
}
// Any specific transformations
// Flight type can be set to P - Passenger, C - Cargo, or H - Charter
$flight->setAttribute('flight_type', FlightType::getFromCode($row['flight_type']));
// Check for a valid value
$flight_type = $row['flight_type'];
if(!array_key_exists($flight_type, FlightType::labels())) {
$flight_type = 'J';
}
$flight->setAttribute('flight_type', $flight_type);
$flight->setAttribute('active', get_truth_state($row['active']));
try {