12848091a2
Update to Laravel 9 and PHP 8+ Co-authored-by: B.Fatih KOZ <fatih.koz@gmail.com>
44 lines
922 B
PHP
44 lines
922 B
PHP
<?php
|
|
|
|
namespace App\Services\ImportExport;
|
|
|
|
use App\Contracts\ImportExport;
|
|
use App\Models\Aircraft;
|
|
|
|
/**
|
|
* The flight importer can be imported or export. Operates on rows
|
|
*/
|
|
class AircraftExporter extends ImportExport
|
|
{
|
|
public $assetType = 'aircraft';
|
|
|
|
/**
|
|
* Set the current columns and other setup
|
|
*/
|
|
public function __construct()
|
|
{
|
|
self::$columns = array_keys(AircraftImporter::$columns);
|
|
}
|
|
|
|
/**
|
|
* Import a flight, parse out the different rows
|
|
*
|
|
* @param Aircraft $aircraft
|
|
*
|
|
* @return array
|
|
*/
|
|
public function export($aircraft): array
|
|
{
|
|
$ret = [];
|
|
foreach (self::$columns as $column) {
|
|
if ($column === 'subfleet') {
|
|
$ret['subfleet'] = $aircraft->subfleet->type;
|
|
} else {
|
|
$ret[$column] = $aircraft->{$column};
|
|
}
|
|
}
|
|
|
|
return $ret;
|
|
}
|
|
}
|