Add aircraft export

This commit is contained in:
Nabeel Shahzad
2018-03-22 12:55:56 -05:00
parent 78e70fec3b
commit d4f79b1331
5 changed files with 81 additions and 4 deletions

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Services\ImportExport;
use App\Interfaces\ImportExport;
use App\Models\Aircraft;
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 = AircraftImporter::$columns;
}
/**
* Import a flight, parse out the different rows
* @param Aircraft $aircraft
* @return array
*/
public function export(Aircraft $aircraft): array
{
$ret = [];
foreach(self::$columns as $column) {
$ret[$column] = $aircraft->{$column};
}
# Modify special fields
$ret['subfleet'] = $aircraft->subfleet->type;
return $ret;
}
}