Add IATA and ZFW to aircraft import/export and tables
This commit is contained in:
@@ -11,10 +11,12 @@ $factory->define(App\Models\Aircraft::class, function (Faker $faker) {
|
||||
'airport_id' => function () {
|
||||
return factory(App\Models\Airport::class)->create()->id;
|
||||
},
|
||||
'iata' => $faker->unique()->text(5),
|
||||
'icao' => $faker->unique()->text(5),
|
||||
'name' => $faker->unique()->text(50),
|
||||
'name' => $faker->text(50),
|
||||
'registration' => $faker->unique()->text(10),
|
||||
'hex_code' => \App\Support\ICAO::createHexCode(),
|
||||
'zfw' => $faker->randomFloat(2, 0, 50000),
|
||||
'status' => \App\Models\Enums\AircraftStatus::ACTIVE,
|
||||
'state' => \App\Models\Enums\AircraftState::PARKED,
|
||||
'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
|
||||
|
||||
@@ -13,6 +13,7 @@ class CreateAircraftsTable extends Migration
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('subfleet_id');
|
||||
$table->string('icao', 4)->nullable();
|
||||
$table->string('iata', 4)->nullable();
|
||||
$table->string('airport_id', 5)->nullable();
|
||||
$table->timestamp('landing_time')->nullable();
|
||||
$table->string('name', 50);
|
||||
@@ -20,7 +21,7 @@ class CreateAircraftsTable extends Migration
|
||||
$table->string('hex_code', 10)->nullable();
|
||||
$table->unsignedDecimal('zfw')->nullable()->default(0);
|
||||
$table->unsignedBigInteger('flight_time')->nullable()->default(0);
|
||||
$table->unsignedTinyInteger('status')->default(AircraftStatus::ACTIVE);
|
||||
$table->char('status', 1)->default(AircraftStatus::ACTIVE);
|
||||
$table->unsignedTinyInteger('state')->default(AircraftState::PARKED);
|
||||
$table->timestamps();
|
||||
|
||||
|
||||
@@ -169,25 +169,25 @@ aircraft:
|
||||
airport_id: KJFK
|
||||
name: Boeing 747-438
|
||||
registration: 001Z
|
||||
status: 1
|
||||
status: A
|
||||
- id: 2
|
||||
subfleet_id: 2
|
||||
airport_id: LGRP
|
||||
name: Boeing 777-200
|
||||
registration: C202
|
||||
status: 1
|
||||
status: A
|
||||
- id: 3
|
||||
subfleet_id: 1
|
||||
airport_id: KAUS
|
||||
name: Boeing 747-412
|
||||
registration: S2333
|
||||
status: 1
|
||||
status: A
|
||||
- id: 4
|
||||
subfleet_id: 1
|
||||
airport_id: KAUS
|
||||
name: Boeing 747-436 RETIRED
|
||||
registration:
|
||||
status: 2
|
||||
status: R
|
||||
|
||||
expenses:
|
||||
- name: Per-Flight (no muliplier)
|
||||
|
||||
@@ -28,8 +28,9 @@ class Aircraft extends Model
|
||||
protected $fillable = [
|
||||
'subfleet_id',
|
||||
'airport_id',
|
||||
'name',
|
||||
'iata',
|
||||
'icao',
|
||||
'name',
|
||||
'registration',
|
||||
'hex_code',
|
||||
'zfw',
|
||||
|
||||
@@ -10,25 +10,17 @@ use App\Interfaces\Enum;
|
||||
*/
|
||||
class AircraftStatus extends Enum
|
||||
{
|
||||
public const STORED = 0;
|
||||
public const ACTIVE = 1;
|
||||
public const RETIRED = 2;
|
||||
public const SCRAPPED = 3;
|
||||
public const WRITTEN_OFF = 4;
|
||||
public const ACTIVE = 'A';
|
||||
public const STORED = 'S';
|
||||
public const RETIRED = 'R';
|
||||
public const SCRAPPED = 'C';
|
||||
public const WRITTEN_OFF = 'W';
|
||||
|
||||
public static $labels = [
|
||||
AircraftStatus::STORED => 'Stored',
|
||||
AircraftStatus::ACTIVE => 'Active',
|
||||
AircraftStatus::STORED => 'Stored',
|
||||
AircraftStatus::RETIRED => 'Retired',
|
||||
AircraftStatus::SCRAPPED => 'Scrapped',
|
||||
AircraftStatus::WRITTEN_OFF => 'Written Off',
|
||||
];
|
||||
|
||||
public static $codes = [
|
||||
AircraftStatus::STORED => 'S',
|
||||
AircraftStatus::ACTIVE => 'A' ,
|
||||
AircraftStatus::RETIRED => 'R',
|
||||
AircraftStatus::SCRAPPED => 'C',
|
||||
AircraftStatus::WRITTEN_OFF => 'W',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ class AircraftExporter extends ImportExport
|
||||
}
|
||||
|
||||
# Modify special fields
|
||||
$ret['status'] = AircraftStatus::convertToCode($aircraft->status);
|
||||
$ret['subfleet'] = $aircraft->subfleet->type;
|
||||
|
||||
return $ret;
|
||||
|
||||
@@ -23,9 +23,12 @@ class AircraftImporter extends ImportExport
|
||||
*/
|
||||
public static $columns = [
|
||||
'subfleet' => 'required',
|
||||
'iata' => 'nullable',
|
||||
'icao' => 'nullable',
|
||||
'name' => 'required',
|
||||
'registration' => 'required',
|
||||
'hex_code' => 'nullable',
|
||||
'zfw' => 'nullable|numeric',
|
||||
'status' => 'nullable',
|
||||
];
|
||||
|
||||
@@ -63,8 +66,6 @@ class AircraftImporter extends ImportExport
|
||||
$row['status'] = trim($row['status']);
|
||||
if($row['status'] === null || $row['status'] === '') {
|
||||
$row['status'] = AircraftStatus::ACTIVE;
|
||||
} else {
|
||||
$row['status'] = AircraftStatus::getFromCode($row['status']);
|
||||
}
|
||||
|
||||
# Just set its state right now as parked
|
||||
|
||||
Reference in New Issue
Block a user