From 3748ab77d21d19dfbcb59cbd664e6a5c887c0b94 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Thu, 22 Feb 2018 14:59:09 -0600 Subject: [PATCH] Fix aircraft active/inactive states --- app/Http/Controllers/Admin/AircraftController.php | 12 +++++++++--- resources/views/admin/aircraft/fields.blade.php | 4 ++-- resources/views/admin/aircraft/table.blade.php | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Admin/AircraftController.php b/app/Http/Controllers/Admin/AircraftController.php index e4a57104..faeed858 100644 --- a/app/Http/Controllers/Admin/AircraftController.php +++ b/app/Http/Controllers/Admin/AircraftController.php @@ -55,8 +55,11 @@ class AircraftController extends BaseController */ public function store(CreateAircraftRequest $request) { - $input = $request->all(); - $aircraft = $this->aircraftRepository->create($input); + $attrs = $request->all(); + + $attrs['active'] = get_truth_state($attrs['active']); + + $aircraft = $this->aircraftRepository->create($attrs); Flash::success('Aircraft saved successfully.'); return redirect(route('admin.aircraft.edit', ['id' => $aircraft->id])); @@ -110,7 +113,10 @@ class AircraftController extends BaseController return redirect(route('admin.aircraft.index')); } - $this->aircraftRepository->update($request->all(), $id); + $attrs = $request->all(); + $attrs['active'] = get_truth_state($attrs['active']); + + $this->aircraftRepository->update($attrs, $id); Flash::success('Aircraft updated successfully.'); return redirect(route('admin.aircraft.index')); diff --git a/resources/views/admin/aircraft/fields.blade.php b/resources/views/admin/aircraft/fields.blade.php index ee820837..ed5561a6 100644 --- a/resources/views/admin/aircraft/fields.blade.php +++ b/resources/views/admin/aircraft/fields.blade.php @@ -38,8 +38,8 @@ {!! Form::label('active', 'Active:') !!}
diff --git a/resources/views/admin/aircraft/table.blade.php b/resources/views/admin/aircraft/table.blade.php index f9427833..9a4a56a0 100644 --- a/resources/views/admin/aircraft/table.blade.php +++ b/resources/views/admin/aircraft/table.blade.php @@ -27,7 +27,7 @@ {!! Utils::minutesToTimeString($ac->flight_hours) !!} - @if($ac->active === GenericState::ACTIVE) + @if($ac->active == GenericState::ACTIVE) {!! GenericState::label($ac->active); !!} @else Inactive