2018-03-23 02:04:13 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Services\ImportExport;
|
|
|
|
|
|
|
|
use App\Interfaces\ImportExport;
|
|
|
|
use App\Models\Airport;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The flight importer can be imported or export. Operates on rows
|
|
|
|
*
|
|
|
|
* @package App\Services\Import
|
|
|
|
*/
|
|
|
|
class AirportExporter extends ImportExport
|
|
|
|
{
|
|
|
|
public $assetType = 'airport';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the current columns and other setup
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
2018-03-31 06:27:29 +08:00
|
|
|
self::$columns = array_keys(AirportImporter::$columns);
|
2018-03-23 02:04:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Import a flight, parse out the different rows
|
|
|
|
* @param Airport $airport
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function export(Airport $airport): array
|
|
|
|
{
|
|
|
|
$ret = [];
|
|
|
|
foreach(self::$columns as $column) {
|
|
|
|
$ret[$column] = $airport->{$column};
|
|
|
|
}
|
|
|
|
|
|
|
|
return $ret;
|
|
|
|
}
|
|
|
|
}
|