Fix aircraft active/inactive states

This commit is contained in:
Nabeel Shahzad 2018-02-22 14:59:09 -06:00
parent 8931f4e271
commit 3748ab77d2
3 changed files with 12 additions and 6 deletions

View File

@ -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'));

View File

@ -38,8 +38,8 @@
{!! Form::label('active', 'Active:') !!}
<br />
<label class="checkbox-inline">
{!! Form::hidden('active', 0, false) !!}
{!! Form::checkbox('active', 1, null) !!}
{!! Form::hidden('active', 0) !!}
{!! Form::checkbox('active') !!}
</label>
</div>
</div>

View File

@ -27,7 +27,7 @@
{!! Utils::minutesToTimeString($ac->flight_hours) !!}
</td>
<td style="text-align: center;">
@if($ac->active === GenericState::ACTIVE)
@if($ac->active == GenericState::ACTIVE)
<span class="label label-success">{!! GenericState::label($ac->active); !!}</span>
@else
<span class="label label-default">Inactive</span>