phpvms/app/Services/ImportExport/FareExporter.php

40 lines
747 B
PHP
Raw Normal View History

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