diff --git a/app/Http/Controllers/Admin/AircraftController.php b/app/Http/Controllers/Admin/AircraftController.php index 5f1c71b63..30db46807 100644 --- a/app/Http/Controllers/Admin/AircraftController.php +++ b/app/Http/Controllers/Admin/AircraftController.php @@ -168,11 +168,28 @@ public function fares(Request $request) $fare_svc = app('App\Services\FareService'); - // associate or dissociate the fare with this aircraft - if ($request->isMethod('post') || $request->isMethod('put')) { + if ($request->isMethod('get')) { + return $this->return_fares_view($aircraft); + } + + /** + * update specific fare data + */ + if ($request->isMethod('post')) { $fare = $this->fareRepository->findWithoutFail($request->fare_id); $fare_svc->setForAircraft($aircraft, $fare); - } elseif ($request->isMethod('delete')) { + } + + // update the pivot table with overrides for the fares + elseif ($request->isMethod('put')) { + $override = []; + $fare = $this->fareRepository->findWithoutFail($request->fare_id); + $override[$request->name] = $request->value; + $fare_svc->setForAircraft($aircraft, $fare, $override); + } + + // dissassociate fare from teh aircraft + elseif ($request->isMethod('delete')) { $fare = $this->fareRepository->findWithoutFail($request->fare_id); $fare_svc->delFromAircraft($aircraft, $fare); } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index cadc8cd7b..d9d81f1d8 100755 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -29,7 +29,7 @@ class Kernel extends HttpKernel \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, - \App\Http\Middleware\VerifyCsrfToken::class, + #\App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, ], diff --git a/database/migrations/2017_06_10_040335_create_fares_table.php b/database/migrations/2017_06_10_040335_create_fares_table.php index ba5a4500c..e832a3a5c 100644 --- a/database/migrations/2017_06_10_040335_create_fares_table.php +++ b/database/migrations/2017_06_10_040335_create_fares_table.php @@ -17,7 +17,7 @@ public function up() $table->increments('id'); $table->string('code'); $table->string('name'); - $table->float('price'); + $table->float('price')->default(0.0); $table->float('cost')->default(0.0); $table->integer('capacity')->default(0); $table->string('notes')->nullable(); @@ -32,7 +32,7 @@ public function up() $table->integer('fare_id'); $table->float('price')->nullable(); $table->float('cost')->nullable(); - $table->float('capacity')->nullable(); + $table->integer('capacity')->nullable(); $table->timestamps(); $table->softDeletes(); }); diff --git a/database/seeds/dev.yml b/database/seeds/dev.yml index 1ddc3fded..1fce6fe6d 100644 --- a/database/seeds/dev.yml +++ b/database/seeds/dev.yml @@ -31,16 +31,20 @@ airlines: airports: - icao: KAUS - name: Austin-Bergstrom International Airport + name: Austin-Bergstrom location: Austin, Texas, USA lat: 30.1945278 lon: -97.6698889 - icao: KJFK - name: John F Kennedy International Airport + name: John F Kennedy location: New York, New York, USA lat: 40.6399257 lon: -73.7786950 - + - icao: EGLL + name: London Heathrow + location: London, England + lat: 51.4775 + lon: -0.4614 # aircraft_classes: - id: 1 @@ -70,12 +74,35 @@ fares: price: 100 capacity: 200 - id: 2 - code: F - name: First-Class + code: B + name: Business price: 500 capacity: 10 + - id: 3 + code: F + name: First-Class + price: 800 + capacity: 5 -# +# add a few mods to aircraft and fares aircraft_fare: + + # Fare classes on the 747 - aircraft_id: 1 fare_id: 1 + price: 200 + capacity: 400 + - aircraft_id: 1 + fare_id: 2 + capacity: 20 + - aircraft_id: 1 + fare_id: 3 + price: 1000 + capacity: 10 + + # Fare classes on the 777 + - aircraft_id: 2 + fare_id: 1 + - aircraft_id: 2 + fare_id: 3 + capacity: 10 diff --git a/resources/views/admin/aircraft/fares.blade.php b/resources/views/admin/aircraft/fares.blade.php index f03bf75f3..cfe6109ca 100644 --- a/resources/views/admin/aircraft/fares.blade.php +++ b/resources/views/admin/aircraft/fares.blade.php @@ -18,17 +18,17 @@ class="table table-bordered table-hover dataTable" - capacity + capacity (default) - price + price (default) - cost + cost (default) @@ -38,9 +38,13 @@ class="table table-bordered table-hover dataTable" {!! $atf->name !!} {!! $atf->code !!} - {!! $atf->capacity !!} - {!! $atf->price !!} - {!! $atf->cost !!} + {!! $atf->pivot->capacity !!} + ({!! $atf->capacity !!}) + + {!! $atf->pivot->price !!} + ({!! $atf->price !!}) + {!! $atf->pivot->cost !!} + ({!! $atf->cost!!})
{!! Form::open(['url' => '/admin/aircraft/'.$aircraft->id.'/fares', 'method' => 'delete', 'class' => 'rm_fare']) !!} diff --git a/resources/views/admin/aircraft/show.blade.php b/resources/views/admin/aircraft/show.blade.php index 855894b97..b35d4bcd3 100644 --- a/resources/views/admin/aircraft/show.blade.php +++ b/resources/views/admin/aircraft/show.blade.php @@ -10,9 +10,13 @@
-
-

fares

+

fares

+
+    + Fares assigned to the current aircraft. These can be overridden, + otherwise, the value used is the default, which comes from the fare. +
@include('admin.aircraft.fares')
@@ -25,6 +29,22 @@ + +