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
|
|
|
|
*/
|
|
|
|
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
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-03-23 02:04:13 +08:00
|
|
|
* @param Airport $airport
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-03-23 02:04:13 +08:00
|
|
|
* @return array
|
|
|
|
*/
|
2018-04-23 21:46:28 +08:00
|
|
|
public function export($airport): array
|
2018-03-23 02:04:13 +08:00
|
|
|
{
|
|
|
|
$ret = [];
|
2018-08-27 00:40:04 +08:00
|
|
|
foreach (self::$columns as $column) {
|
2018-03-23 02:04:13 +08:00
|
|
|
$ret[$column] = $airport->{$column};
|
|
|
|
}
|
|
|
|
|
|
|
|
return $ret;
|
|
|
|
}
|
|
|
|
}
|