Add MTOW and ZFW to aircraft editor #775
This commit is contained in:
@@ -1,24 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Models\Airport;
|
||||||
|
use App\Models\Enums\AircraftState;
|
||||||
|
use App\Models\Enums\AircraftStatus;
|
||||||
|
use App\Models\Subfleet;
|
||||||
|
use App\Support\ICAO;
|
||||||
use Faker\Generator as Faker;
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
$factory->define(App\Models\Aircraft::class, function (Faker $faker) {
|
$factory->define(App\Models\Aircraft::class, function (Faker $faker) {
|
||||||
return [
|
return [
|
||||||
'id' => null,
|
'id' => null,
|
||||||
'subfleet_id' => function () {
|
'subfleet_id' => function () {
|
||||||
return factory(\App\Models\Subfleet::class)->create()->id;
|
return factory(Subfleet::class)->create()->id;
|
||||||
},
|
},
|
||||||
'airport_id' => function () {
|
'airport_id' => function () {
|
||||||
return factory(\App\Models\Airport::class)->create()->id;
|
return factory(Airport::class)->create()->id;
|
||||||
},
|
},
|
||||||
'iata' => $faker->unique()->text(5),
|
'iata' => $faker->unique()->text(5),
|
||||||
'icao' => $faker->unique()->text(5),
|
'icao' => $faker->unique()->text(5),
|
||||||
'name' => $faker->text(50),
|
'name' => $faker->text(50),
|
||||||
'registration' => $faker->unique()->text(10),
|
'registration' => $faker->unique()->text(10),
|
||||||
'hex_code' => \App\Support\ICAO::createHexCode(),
|
'hex_code' => ICAO::createHexCode(),
|
||||||
|
'mtow' => $faker->randomFloat(2, 0, 50000),
|
||||||
'zfw' => $faker->randomFloat(2, 0, 50000),
|
'zfw' => $faker->randomFloat(2, 0, 50000),
|
||||||
'status' => \App\Models\Enums\AircraftStatus::ACTIVE,
|
'status' => AircraftStatus::ACTIVE,
|
||||||
'state' => \App\Models\Enums\AircraftState::PARKED,
|
'state' => AircraftState::PARKED,
|
||||||
'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
|
'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
|
||||||
'updated_at' => function (array $pirep) {
|
'updated_at' => function (array $pirep) {
|
||||||
return $pirep['created_at'];
|
return $pirep['created_at'];
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a `mtow` column for the max takeoff weight
|
||||||
|
*/
|
||||||
|
class AircraftAddMtow extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('aircraft', function (Blueprint $table) {
|
||||||
|
$table->unsignedDecimal('mtow')
|
||||||
|
->nullable()
|
||||||
|
->default(0.0)
|
||||||
|
->after('hex_code');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('aircraft', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('mtow');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,8 @@ use Carbon\Carbon;
|
|||||||
* @property string icao
|
* @property string icao
|
||||||
* @property string registration
|
* @property string registration
|
||||||
* @property int flight_time
|
* @property int flight_time
|
||||||
|
* @property float mtow
|
||||||
|
* @property float zfw
|
||||||
* @property string hex_code
|
* @property string hex_code
|
||||||
* @property Airport airport
|
* @property Airport airport
|
||||||
* @property Subfleet subfleet
|
* @property Subfleet subfleet
|
||||||
@@ -39,6 +41,7 @@ class Aircraft extends Model
|
|||||||
'registration',
|
'registration',
|
||||||
'hex_code',
|
'hex_code',
|
||||||
'flight_time',
|
'flight_time',
|
||||||
|
'mtow',
|
||||||
'zfw',
|
'zfw',
|
||||||
'status',
|
'status',
|
||||||
'state',
|
'state',
|
||||||
@@ -49,6 +52,7 @@ class Aircraft extends Model
|
|||||||
*/
|
*/
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'subfleet_id' => 'integer',
|
'subfleet_id' => 'integer',
|
||||||
|
'mtow' => 'float',
|
||||||
'zfw' => 'float',
|
'zfw' => 'float',
|
||||||
'flight_time' => 'float',
|
'flight_time' => 'float',
|
||||||
'state' => 'integer',
|
'state' => 'integer',
|
||||||
@@ -62,6 +66,8 @@ class Aircraft extends Model
|
|||||||
'name' => 'required',
|
'name' => 'required',
|
||||||
'status' => 'required',
|
'status' => 'required',
|
||||||
'registration' => 'required',
|
'registration' => 'required',
|
||||||
|
'mtow' => 'nullable|number',
|
||||||
|
'zfw' => 'nullable|number',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -37,18 +37,15 @@
|
|||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="form-container">
|
<div class="form-container">
|
||||||
<h6>
|
<h6>
|
||||||
<span style="float:right">
|
<span style="float:right">
|
||||||
View list of
|
View list of
|
||||||
<a href="https://en.wikipedia.org/wiki/List_of_ICAO_aircraft_type_designators"
|
<a href="https://en.wikipedia.org/wiki/List_of_ICAO_aircraft_type_designators"
|
||||||
target="_blank">
|
target="_blank">IATA and ICAO Type Designators</a>
|
||||||
IATA and ICAO Type Designators
|
</span>
|
||||||
</a>
|
<i class="fas fa-plane"></i> Aircraft Information
|
||||||
</span>
|
|
||||||
<i class="fas fa-plane"></i>
|
|
||||||
Aircraft Information
|
|
||||||
|
|
||||||
</h6>
|
</h6>
|
||||||
<div class="form-container-body">
|
<div class="form-container-body">
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-sm-12">
|
<div class="form-group col-sm-12">
|
||||||
{{ Form::label('name', 'Name:') }} <span class="required">*</span>
|
{{ Form::label('name', 'Name:') }} <span class="required">*</span>
|
||||||
@@ -56,6 +53,7 @@
|
|||||||
<p class="text-danger">{{ $errors->first('name') }}</p>
|
<p class="text-danger">{{ $errors->first('name') }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-sm-3">
|
<div class="form-group col-sm-3">
|
||||||
{{ Form::label('iata', 'IATA:') }}
|
{{ Form::label('iata', 'IATA:') }}
|
||||||
@@ -75,6 +73,20 @@
|
|||||||
<p class="text-danger">{{ $errors->first('registration') }}</p>
|
<p class="text-danger">{{ $errors->first('registration') }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-sm-6">
|
||||||
|
{{ Form::label('mtow', 'Max Takeoff Weight (MTOW):') }}
|
||||||
|
{{ Form::text('mtow', null, ['class' => 'form-control']) }}
|
||||||
|
<p class="text-danger">{{ $errors->first('mtow') }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-sm-6">
|
||||||
|
{{ Form::label('zfw', 'Zero Fuel Weight (ZFW):') }}
|
||||||
|
{{ Form::text('zfw', null, ['class' => 'form-control']) }}
|
||||||
|
<p class="text-danger">{{ $errors->first('zfw') }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -242,13 +242,17 @@ class ApiTest extends TestCase
|
|||||||
|
|
||||||
$fare_svc = app(FareService::class);
|
$fare_svc = app(FareService::class);
|
||||||
|
|
||||||
|
/** @var Subfleet $subfleet */
|
||||||
$subfleet = factory(Subfleet::class)->create([
|
$subfleet = factory(Subfleet::class)->create([
|
||||||
'airline_id' => $this->user->airline_id,
|
'airline_id' => $this->user->airline_id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
/** @var Fare $fare */
|
||||||
$fare = factory(Fare::class)->create();
|
$fare = factory(Fare::class)->create();
|
||||||
|
|
||||||
$fare_svc->setForSubfleet($subfleet, $fare);
|
$fare_svc->setForSubfleet($subfleet, $fare);
|
||||||
|
|
||||||
|
/** @var Aircraft $aircraft */
|
||||||
$aircraft = factory(Aircraft::class)->create([
|
$aircraft = factory(Aircraft::class)->create([
|
||||||
'subfleet_id' => $subfleet->id,
|
'subfleet_id' => $subfleet->id,
|
||||||
]);
|
]);
|
||||||
@@ -258,15 +262,27 @@ class ApiTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
$resp = $this->get('/api/fleet/aircraft/'.$aircraft->id);
|
$resp = $this->get('/api/fleet/aircraft/'.$aircraft->id);
|
||||||
$body = $resp->json()['data'];
|
$body = $resp->json()['data'];
|
||||||
|
|
||||||
$this->assertEquals($body['id'], $aircraft->id);
|
$this->assertEquals($body['id'], $aircraft->id);
|
||||||
|
$this->assertEquals($body['name'], $aircraft->name);
|
||||||
|
$this->assertEquals($body['mtow'], $aircraft->mtow);
|
||||||
|
$this->assertEquals($body['zfw'], $aircraft->zfw);
|
||||||
|
|
||||||
$resp = $this->get('/api/fleet/aircraft/'.$aircraft->id.'?registration='.$aircraft->registration);
|
$resp = $this->get('/api/fleet/aircraft/'.$aircraft->id.'?registration='.$aircraft->registration);
|
||||||
$body = $resp->json()['data'];
|
$body = $resp->json()['data'];
|
||||||
|
|
||||||
$this->assertEquals($body['id'], $aircraft->id);
|
$this->assertEquals($body['id'], $aircraft->id);
|
||||||
|
$this->assertEquals($body['name'], $aircraft->name);
|
||||||
|
$this->assertEquals($body['mtow'], $aircraft->mtow);
|
||||||
|
$this->assertEquals($body['zfw'], $aircraft->zfw);
|
||||||
|
|
||||||
$resp = $this->get('/api/fleet/aircraft/'.$aircraft->id.'?icao='.$aircraft->icao);
|
$resp = $this->get('/api/fleet/aircraft/'.$aircraft->id.'?icao='.$aircraft->icao);
|
||||||
$body = $resp->json()['data'];
|
$body = $resp->json()['data'];
|
||||||
|
|
||||||
$this->assertEquals($body['id'], $aircraft->id);
|
$this->assertEquals($body['id'], $aircraft->id);
|
||||||
|
$this->assertEquals($body['name'], $aircraft->name);
|
||||||
|
$this->assertEquals($body['mtow'], $aircraft->mtow);
|
||||||
|
$this->assertEquals($body['zfw'], $aircraft->zfw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetAllSettings()
|
public function testGetAllSettings()
|
||||||
|
|||||||
Reference in New Issue
Block a user