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