From 4142d5d28ab63827295a2556b79a03de254499e4 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Fri, 23 Feb 2018 15:48:50 -0600 Subject: [PATCH] Add ground_handling_cost to airport #134 --- app/Database/factories/AirportFactory.php | 7 ++- ...017_06_11_135707_create_airports_table.php | 1 + app/Database/seeds/sample.yml | 49 ++-------------- app/Models/Airport.php | 15 +++-- .../views/admin/airports/fields.blade.php | 58 ++++++++++++------- .../views/admin/airports/table.blade.php | 4 ++ 6 files changed, 60 insertions(+), 74 deletions(-) diff --git a/app/Database/factories/AirportFactory.php b/app/Database/factories/AirportFactory.php index def85245..9c5c5d86 100644 --- a/app/Database/factories/AirportFactory.php +++ b/app/Database/factories/AirportFactory.php @@ -25,8 +25,9 @@ $factory->define(App\Models\Airport::class, function (Faker $faker) { 'timezone' => $faker->timezone, 'lat' => $faker->latitude, 'lon' => $faker->longitude, - 'fuel_100ll_cost' => $faker->randomFloat(2), - 'fuel_jeta_cost' => $faker->randomFloat(2), - 'fuel_mogas_cost' => $faker->randomFloat(2), + 'ground_handling_cost' => $faker->randomFloat(2, 0, 500), + 'fuel_100ll_cost' => $faker->randomFloat(2, 0, 100), + 'fuel_jeta_cost' => $faker->randomFloat(2, 0, 100), + 'fuel_mogas_cost' => $faker->randomFloat(2, 0, 100), ]; }); diff --git a/app/Database/migrations/2017_06_11_135707_create_airports_table.php b/app/Database/migrations/2017_06_11_135707_create_airports_table.php index 71feb7f1..863732b2 100644 --- a/app/Database/migrations/2017_06_11_135707_create_airports_table.php +++ b/app/Database/migrations/2017_06_11_135707_create_airports_table.php @@ -16,6 +16,7 @@ class CreateAirportsTable extends Migration $table->string('country', 64)->nullable(); $table->string('timezone', 64)->nullable(); $table->boolean('hub')->default(false); + $table->unsignedDecimal('ground_handling_cost')->nullable()->default(0); $table->unsignedDecimal('fuel_100ll_cost')->nullable()->default(0); $table->unsignedDecimal('fuel_jeta_cost')->nullable()->default(0); $table->unsignedDecimal('fuel_mogas_cost')->nullable()->default(0); diff --git a/app/Database/seeds/sample.yml b/app/Database/seeds/sample.yml index 94d7ed56..6ada63f9 100644 --- a/app/Database/seeds/sample.yml +++ b/app/Database/seeds/sample.yml @@ -115,6 +115,7 @@ airports: lat: 30.1945278 lon: -97.6698889 hub: 1 + ground_handling_cost: 100 - id: KJFK iata: JFK icao: KJFK @@ -125,51 +126,7 @@ airports: lat: 40.6399257 lon: -73.7786950 hub: 1 - - id: KBWI - iata: BWI - icao: KBWI - name: Baltimore/Washington International Thurgood Marshall Airport - location: Baltimore, MD - country: United States - timezone: America/New_York - lat: 39.1754 - lon: -76.6683 - - id: KIAH - iata: IAH - icao: KIAH - name: George Bush Intercontinental Houston Airport - location: Houston, TX - country: United States - timezone: America/Chicago - lat: 29.9844 - lon: -95.3414 - - id: KORD - iata: ORD - icao: KORD - name: Chicago O'Hare International Airport - location: Chicago, IL - country: United States - timezone: America/Chicago - lat: 41.9786 - lon: -87.9048 - - id: KDFW - iata: DFW - icao: KDFW - name: Dallas Fort Worth International Airport - location: Dallas, TX - country: United States - timezone: America/Chicago - lat: 32.8968 - lon: -97.038 - - id: EFHK - iata: HEL - icao: EFHK - name: Helsinki Vantaa Airport - location: Helsinki - country: Finland - timezone: Europe/Helsinki - lat: 60.3172 - lon: 24.9633 + ground_handling_cost: 250 - id: EGLL iata: LHR icao: EGLL @@ -178,6 +135,7 @@ airports: timezone: Europe/London lat: 51.4775 lon: -0.4614 + ground_handling_cost: 500 - id: LGRP iata: RHO icao: LGRP @@ -187,6 +145,7 @@ airports: timezone: Europe/Athens lat: 36.4054 lon: 28.0862 + ground_handling_cost: 50 # aircraft: - id: 1 diff --git a/app/Models/Airport.php b/app/Models/Airport.php index 165cdf7f..0d81f776 100644 --- a/app/Models/Airport.php +++ b/app/Models/Airport.php @@ -27,6 +27,7 @@ class Airport extends BaseModel 'lon', 'hub', 'timezone', + 'ground_handling_cost', 'fuel_100ll_cost', 'fuel_jeta_cost', 'fuel_mogas_cost', @@ -36,6 +37,7 @@ class Airport extends BaseModel 'lat' => 'float', 'lon' => 'float', 'hub' => 'boolean', + 'ground_handling_cost' => 'float', 'fuel_100ll_cost' => 'float', 'fuel_jeta_cost' => 'float', 'fuel_mogas_cost' => 'float', @@ -45,12 +47,13 @@ class Airport extends BaseModel * Validation rules */ public static $rules = [ - 'icao' => 'required', - 'iata' => 'nullable', - 'name' => 'required', - 'location' => 'nullable', - 'lat' => 'required|numeric', - 'lon' => 'required|numeric', + 'icao' => 'required', + 'iata' => 'nullable', + 'name' => 'required', + 'location' => 'nullable', + 'lat' => 'required|numeric', + 'lon' => 'required|numeric', + 'ground_handling_cost' => 'nullable|numeric', ]; /** diff --git a/resources/views/admin/airports/fields.blade.php b/resources/views/admin/airports/fields.blade.php index 0c54f99b..09f9db52 100644 --- a/resources/views/admin/airports/fields.blade.php +++ b/resources/views/admin/airports/fields.blade.php @@ -12,20 +12,26 @@
+ {!! Form::label('iata', 'IATA:') !!} + {!! Form::text('iata', null, ['class' => 'form-control']) !!} +

{{ $errors->first('iata') }}

+
+ + + +
+
{!! Form::label('name', 'Name:') !!} * {!! Form::text('name', null, ['class' => 'form-control']) !!}

{{ $errors->first('name') }}

-
- -
-
+
{!! Form::label('lat', 'Latitude:') !!} * {!! Form::number('lat', null, ['class' => 'form-control', 'step' => '0.000001', 'rv-value' => 'airport.lat']) !!}

{{ $errors->first('lat') }}

-
+
{!! Form::label('lon', 'Longitude:') !!} * {!! Form::number('lon', null, ['class' => 'form-control', 'step' => '0.000001', 'rv-value' => 'airport.lon']) !!}

{{ $errors->first('lon') }}

@@ -33,33 +39,45 @@
-
- {!! Form::label('iata', 'IATA:') !!} - {!! Form::text('iata', null, ['class' => 'form-control']) !!} -

{{ $errors->first('iata') }}

-
-
- {!! Form::label('location', 'Location:') !!} - {!! Form::text('location', null, ['class' => 'form-control']) !!} -

{{ $errors->first('location') }}

-
-
- -
-
+
{!! Form::label('country', 'Country:') !!} {!! Form::text('country', null, ['class' => 'form-control']) !!}

{{ $errors->first('country') }}

-
+
+ {!! Form::label('location', 'Location:') !!} + {!! Form::text('location', null, ['class' => 'form-control']) !!} +

{{ $errors->first('location') }}

+
+ +
{!! Form::label('timezone', 'Timezone:') !!} {!! Form::select('timezone', $timezones, null, ['id' => 'timezone', 'class' => 'select2']); !!}

{{ $errors->first('timezone') }}

+
+
+ {!! Form::label('ground_handling_cost', 'Ground Handling Cost:') !!} + + @component('admin.components.info') + This is the base rate per-flight. A multiplier for this rate can be + set in the subfleet, so you can modulate those costs from there. + @endcomponent + + {!! Form::number('ground_handling_cost', null, ['class' => 'form-control']) !!} +

{{ $errors->first('ground_handling_cost') }}

+
+ +
+ +
+ +
+
{!! Form::label('hub', 'Hub:') !!} diff --git a/resources/views/admin/airports/table.blade.php b/resources/views/admin/airports/table.blade.php index 0269996e..3f28ff90 100644 --- a/resources/views/admin/airports/table.blade.php +++ b/resources/views/admin/airports/table.blade.php @@ -5,6 +5,7 @@ Name Location Hub + GH Cost 100LL JetA MOGAS @@ -21,6 +22,9 @@ Hub @endif + + {!! $airport->ground_handling_cost !!} + {!! $airport->fuel_100ll_cost !!}