Export extra fields for airports

This commit is contained in:
Nabeel Shahzad
2018-07-12 22:21:39 -05:00
parent 761c845300
commit f640381978
2 changed files with 19 additions and 15 deletions

View File

@@ -18,15 +18,19 @@ class AirportImporter extends ImportExport
* Should match the database fields, for the most part
*/
public static $columns = [
'icao' => 'required',
'iata' => 'required',
'name' => 'required',
'location' => 'nullable',
'country' => 'nullable',
'timezone' => 'nullable',
'hub' => 'nullable|boolean',
'lat' => 'required|numeric',
'lon' => 'required|numeric',
'icao' => 'required',
'iata' => 'required',
'name' => 'required',
'location' => 'nullable',
'country' => 'nullable',
'timezone' => 'nullable',
'hub' => 'nullable|boolean',
'lat' => 'required|numeric',
'lon' => 'required|numeric',
'ground_handling_cost' => 'nullable|float',
'fuel_100ll_cost' => 'nullable|float',
'fuel_jeta_cost' => 'nullable|float',
'fuel_mogas_cost' => 'nullable|float',
];
/**
@@ -41,12 +45,12 @@ class AirportImporter extends ImportExport
$row['hub'] = get_truth_state($row['hub']);
$airport = Airport::firstOrNew([
'id' => $row['icao']
'id' => $row['icao']
], $row);
try {
$airport->save();
} catch(\Exception $e) {
} catch (\Exception $e) {
$this->errorLog('Error in row '.$index.': '.$e->getMessage());
return false;
}

View File

@@ -1,4 +1,4 @@
icao,iata,name,location,country,timezone,hub,lat,lon
KAUS,AUS,Austin-Bergstrom,"Austin, Texas, USA", United States,America/Chicago,1,30.1945,-97.6699
KSFO,SFO,San Francisco,"San Francisco, California, USA", United States,America/California,"1",30.1945,-97.6699
KJFK,JFK,Kennedy,"Queens, New York, USA", United States,America/New_York,0,30.1945,abcd
icao,iata,name,location,country,timezone,hub,lat,lon,ground_handling_cost,fuel_100ll_cost,fuel_jeta_cost,fuel_mogas_cost
KAUS,AUS,Austin-Bergstrom,"Austin, Texas, USA", United States,America/Chicago,1,30.1945,-97.6699,,,,
KSFO,SFO,San Francisco,"San Francisco, California, USA", United States,America/California,"1",30.1945,-97.6699,,,,
KJFK,JFK,Kennedy,"Queens, New York, USA", United States,America/New_York,0,30.1945,abcd,,,,
1 icao iata name location country timezone hub lat lon ground_handling_cost fuel_100ll_cost fuel_jeta_cost fuel_mogas_cost
2 KAUS AUS Austin-Bergstrom Austin, Texas, USA United States America/Chicago 1 30.1945 -97.6699
3 KSFO SFO San Francisco San Francisco, California, USA United States America/California 1 30.1945 -97.6699
4 KJFK JFK Kennedy Queens, New York, USA United States America/New_York 0 30.1945 abcd