From b8b4fe7a8ae2220327c4c1d3236199c2a2345e70 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Fri, 23 Feb 2018 15:34:14 -0600 Subject: [PATCH] Add percentages as part of sample data #125 --- app/Database/seeds/sample.yml | 4 ++-- app/Http/Controllers/Admin/FlightController.php | 14 ++++++++++---- resources/views/admin/flights/fares.blade.php | 2 ++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/Database/seeds/sample.yml b/app/Database/seeds/sample.yml index e17170aa..94d7ed56 100644 --- a/app/Database/seeds/sample.yml +++ b/app/Database/seeds/sample.yml @@ -239,11 +239,11 @@ subfleet_fare: capacity: 400 - subfleet_id: 1 fare_id: 2 - capacity: 20 + price: 120% - subfleet_id: 1 fare_id: 3 price: 1000 - capacity: 10 + capacity: 110% # Fare classes on the 777 - subfleet_id: 2 diff --git a/app/Http/Controllers/Admin/FlightController.php b/app/Http/Controllers/Admin/FlightController.php index eb63c2fd..f0cb8662 100644 --- a/app/Http/Controllers/Admin/FlightController.php +++ b/app/Http/Controllers/Admin/FlightController.php @@ -395,6 +395,16 @@ class FlightController extends BaseController return $this->return_fares_view($flight); } + if ($request->isMethod('delete')) { + $fare = $this->fareRepo->findWithoutFail($request->fare_id); + $this->fareSvc->delFareFromFlight($flight, $fare); + return $this->return_fares_view($flight); + } + + $this->validate($request, [ + 'value' => 'nullable', // regex:/([\d%]*)/ + ]); + /** * update specific fare data */ @@ -408,10 +418,6 @@ class FlightController extends BaseController $override[$request->name] = $request->value; $this->fareSvc->setForFlight($flight, $fare, $override); } // dissassociate fare from teh aircraft - elseif ($request->isMethod('delete')) { - $fare = $this->fareRepo->findWithoutFail($request->fare_id); - $this->fareSvc->delFareFromFlight($flight, $fare); - } return $this->return_fares_view($flight); } diff --git a/resources/views/admin/flights/fares.blade.php b/resources/views/admin/flights/fares.blade.php index 060d262d..16506256 100644 --- a/resources/views/admin/flights/fares.blade.php +++ b/resources/views/admin/flights/fares.blade.php @@ -9,6 +9,8 @@ Read documentation about finances. @endcomponent + +

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