diff --git a/app/Http/Controllers/Admin/AircraftController.php b/app/Http/Controllers/Admin/AircraftController.php index c8f8a8985..509312b71 100644 --- a/app/Http/Controllers/Admin/AircraftController.php +++ b/app/Http/Controllers/Admin/AircraftController.php @@ -43,26 +43,38 @@ public function __construct( /** * Display a listing of the Aircraft. - * @throws \Prettus\Repository\Exceptions\RepositoryException + * @param Request $request + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function index(Request $request) { - $this->aircraftRepo->pushCriteria(new RequestCriteria($request)); - $aircraft = $this->aircraftRepo->orderBy('registration', 'asc')->all(); + // If subfleet ID is passed part of the query string, then only + // show the aircraft that are in that subfleet + $w = []; + if($request->filled('subfleet')) { + $w['subfleet_id'] = $request->input('subfleet'); + } + + $aircraft = $this->aircraftRepo->whereOrder($w, 'registration', 'asc'); + $aircraft = $aircraft->all(); return view('admin.aircraft.index', [ - 'aircraft' => $aircraft + 'aircraft' => $aircraft, + 'subfleet_id' => $request->input('subfleet'), ]); } /** * Show the form for creating a new Aircraft. + * @param Request $request + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ - public function create() + public function create(Request $request) { return view('admin.aircraft.create', [ 'subfleets' => Subfleet::all()->pluck('name', 'id'), 'statuses' => AircraftStatus::select(true), + 'subfleet_id' => $request->query('subfleet') ]); } diff --git a/resources/views/admin/aircraft/fields.blade.php b/resources/views/admin/aircraft/fields.blade.php index 28e33c057..639f18b0c 100644 --- a/resources/views/admin/aircraft/fields.blade.php +++ b/resources/views/admin/aircraft/fields.blade.php @@ -1,7 +1,11 @@
{{ Form::label('subfleet_id', 'Subfleet:') }} - {{ Form::select('subfleet_id', $subfleets, null, ['class' => 'form-control select2', 'placeholder' => 'Select Subfleet']) }} + {{ Form::select('subfleet_id', $subfleets, $subfleet_id ?? null, [ + 'class' => 'form-control select2', + 'placeholder' => 'Select Subfleet' + ]) + }}

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

diff --git a/resources/views/admin/aircraft/index.blade.php b/resources/views/admin/aircraft/index.blade.php index 7b99af5e9..25666c0c9 100644 --- a/resources/views/admin/aircraft/index.blade.php +++ b/resources/views/admin/aircraft/index.blade.php @@ -4,8 +4,9 @@ @section('actions')
  • Export to CSV
  • Import from CSV
  • -
  • Subfleets
  • -
  • New Aircraft
  • + {{--
  • Subfleets
  • --}} +
  • + New Aircraft
  • @endsection @section('content') diff --git a/resources/views/admin/menu.blade.php b/resources/views/admin/menu.blade.php index 848c44646..f38c192ce 100644 --- a/resources/views/admin/menu.blade.php +++ b/resources/views/admin/menu.blade.php @@ -16,7 +16,7 @@ class="badge bg-light-blue pull-right">3
  • flights
  • -
  • fleet
  • +
  • fleet
  • fares
  • finances
  • @@ -31,9 +31,9 @@ class="badge bg-light-blue pull-right">3