From 65e58c91c5fc69e94911a0b8d0f6cad2f0908b72 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Mon, 19 Jun 2017 13:13:31 -0500 Subject: [PATCH] cleanup for aircraft fares --- app/Http/Controllers/Admin/AircraftController.php | 15 +++++---------- resources/views/admin/aircraft/fares.blade.php | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/Admin/AircraftController.php b/app/Http/Controllers/Admin/AircraftController.php index 30db4680..78aeecc1 100644 --- a/app/Http/Controllers/Admin/AircraftController.php +++ b/app/Http/Controllers/Admin/AircraftController.php @@ -16,10 +16,11 @@ class AircraftController extends BaseController /** @var AircraftRepository */ private $aircraftRepository, $fareRepository; - protected function getAvailFares($all_fares, $attached_fares) + protected function getAvailFares($aircraft) { $retval = []; - $avail_fares = $all_fares->except($attached_fares->modelKeys()); + $all_fares = $this->fareRepository->all(); + $avail_fares = $all_fares->except($aircraft->fares->modelKeys()); foreach ($avail_fares as $fare) { $retval[$fare->id] = $fare->name. ' (price: '.$fare->price. @@ -81,13 +82,10 @@ class AircraftController extends BaseController return redirect(route('admin.aircraft.index')); } - $attached_fares = $aircraft->fares; - $all_fares = $this->fareRepository->all(); - $avail_fares = $this->getAvailFares($all_fares, $attached_fares); + $avail_fares = $this->getAvailFares($aircraft); return view('admin.aircraft.show') ->with('aircraft', $aircraft) - ->with('attached_fares', $attached_fares) ->with('avail_fares', $avail_fares); } @@ -147,13 +145,10 @@ class AircraftController extends BaseController protected function return_fares_view($aircraft) { $aircraft->refresh(); - $attached_fares = $aircraft->fares; - $all_fares = $this->fareRepository->all(); - $avail_fares = $this->getAvailFares($all_fares, $attached_fares); + $avail_fares = $this->getAvailFares($aircraft); return view('admin.aircraft.fares') ->with('aircraft', $aircraft) - ->with('attached_fares', $attached_fares) ->with('avail_fares', $avail_fares); } diff --git a/resources/views/admin/aircraft/fares.blade.php b/resources/views/admin/aircraft/fares.blade.php index cfe6109c..b6e40f8a 100644 --- a/resources/views/admin/aircraft/fares.blade.php +++ b/resources/views/admin/aircraft/fares.blade.php @@ -34,7 +34,7 @@ - @foreach($attached_fares as $atf) + @foreach($aircraft->fares as $atf) {!! $atf->name !!} {!! $atf->code !!}