phpvms/app/Services/ImportExport/AircraftExporter.php

45 lines
947 B
PHP
Raw Normal View History

2018-03-23 01:55:56 +08:00
<?php
namespace App\Services\ImportExport;
use App\Interfaces\ImportExport;
use App\Models\Aircraft;
2018-03-23 08:59:35 +08:00
use App\Models\Enums\AircraftStatus;
2018-03-23 01:55:56 +08:00
use App\Models\Flight;
/**
* The flight importer can be imported or export. Operates on rows
*
* @package App\Services\Import
*/
class AircraftExporter extends ImportExport
{
public $assetType = 'aircraft';
/**
* Set the current columns and other setup
*/
public function __construct()
{
self::$columns = array_keys(AircraftImporter::$columns);
2018-03-23 01:55:56 +08:00
}
/**
* Import a flight, parse out the different rows
* @param Aircraft $aircraft
* @return array
*/
2018-04-23 21:46:28 +08:00
public function export($aircraft): array
2018-03-23 01:55:56 +08:00
{
$ret = [];
foreach(self::$columns as $column) {
$ret[$column] = $aircraft->{$column};
}
# Modify special fields
$ret['subfleet'] = $aircraft->subfleet->type;
return $ret;
}
}