Load subfleet page first, can add aircraft from there #217

This commit is contained in:
Nabeel Shahzad 2018-03-23 20:30:31 -05:00
parent 1eb7e5d59a
commit 0671742703
7 changed files with 49 additions and 18 deletions

View File

@ -43,26 +43,38 @@ class AircraftController extends Controller
/** /**
* Display a listing of the Aircraft. * 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) public function index(Request $request)
{ {
$this->aircraftRepo->pushCriteria(new RequestCriteria($request)); // If subfleet ID is passed part of the query string, then only
$aircraft = $this->aircraftRepo->orderBy('registration', 'asc')->all(); // 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', [ return view('admin.aircraft.index', [
'aircraft' => $aircraft 'aircraft' => $aircraft,
'subfleet_id' => $request->input('subfleet'),
]); ]);
} }
/** /**
* Show the form for creating a new Aircraft. * 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', [ return view('admin.aircraft.create', [
'subfleets' => Subfleet::all()->pluck('name', 'id'), 'subfleets' => Subfleet::all()->pluck('name', 'id'),
'statuses' => AircraftStatus::select(true), 'statuses' => AircraftStatus::select(true),
'subfleet_id' => $request->query('subfleet')
]); ]);
} }

View File

@ -1,7 +1,11 @@
<div class="row"> <div class="row">
<div class="form-group col-sm-6"> <div class="form-group col-sm-6">
{{ Form::label('subfleet_id', 'Subfleet:') }} {{ 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'
])
}}
<p class="text-danger">{{ $errors->first('subfleet_id') }}</p> <p class="text-danger">{{ $errors->first('subfleet_id') }}</p>
</div> </div>

View File

@ -4,8 +4,9 @@
@section('actions') @section('actions')
<li><a href="{{ route('admin.aircraft.export') }}"><i class="ti-plus"></i>Export to CSV</a></li> <li><a href="{{ route('admin.aircraft.export') }}"><i class="ti-plus"></i>Export to CSV</a></li>
<li><a href="{{ route('admin.aircraft.import') }}"><i class="ti-plus"></i>Import from CSV</a></li> <li><a href="{{ route('admin.aircraft.import') }}"><i class="ti-plus"></i>Import from CSV</a></li>
<li><a href="{{ url('/admin/subfleets') }}"><i class="ti-files"></i>Subfleets</a></li> {{--<li><a href="{{ url('/admin/subfleets') }}"><i class="ti-files"></i>Subfleets</a></li>--}}
<li><a href="{{ route('admin.aircraft.create') }}"><i class="ti-plus"></i>New Aircraft</a></li> <li><a href="{{ route('admin.aircraft.create') }}?subfleet={{$subfleet_id}}">
<i class="ti-plus"></i>New Aircraft</a></li>
@endsection @endsection
@section('content') @section('content')

View File

@ -16,7 +16,7 @@
</a> </a>
</li> </li>
<li><a href="{{ url('/admin/flights') }}"><i class="pe-7s-vector"></i>flights</a></li> <li><a href="{{ url('/admin/flights') }}"><i class="pe-7s-vector"></i>flights</a></li>
<li><a href="{{ url('/admin/aircraft') }}"><i class="pe-7s-plane"></i>fleet</a></li> <li><a href="{{ url('/admin/subfleets') }}"><i class="pe-7s-plane"></i>fleet</a></li>
<li><a href="{{ url('/admin/fares') }}"><i class="pe-7s-graph2"></i>fares</a></li> <li><a href="{{ url('/admin/fares') }}"><i class="pe-7s-graph2"></i>fares</a></li>
<li><a href="{{ url('/admin/finances') }}"><i class="pe-7s-display1"></i>finances</a></li> <li><a href="{{ url('/admin/finances') }}"><i class="pe-7s-display1"></i>finances</a></li>
</ul> </ul>
@ -31,9 +31,9 @@
<div class="collapse" id="config_menu" aria-expanded="true"> <div class="collapse" id="config_menu" aria-expanded="true">
<ul class="nav"> <ul class="nav">
<li><a href="{{ url('/admin/airlines') }}"><i <li><a href="{{ url('/admin/airlines') }}"><i
class="pe-7s-paper-plane"></i>airlines</a></li> class="pe-7s-paper-plane"></i>airlines</a></li>
<li><a href="{{ url('/admin/airports') }}"><i <li><a href="{{ url('/admin/airports') }}"><i
class="pe-7s-map-marker"></i>airports</a></li> class="pe-7s-map-marker"></i>airports</a></li>
<li><a href="{{ url('/admin/expenses') }}"><i class="pe-7s-cash"></i>expenses</a></li> <li><a href="{{ url('/admin/expenses') }}"><i class="pe-7s-cash"></i>expenses</a></li>
<li><a href="{{ url('/admin/users') }}"><i class="pe-7s-users"></i>users</a></li> <li><a href="{{ url('/admin/users') }}"><i class="pe-7s-users"></i>users</a></li>
<li><a href="{{ url('/admin/ranks') }}"><i class="pe-7s-graph1"></i>ranks</a></li> <li><a href="{{ url('/admin/ranks') }}"><i class="pe-7s-graph1"></i>ranks</a></li>

View File

@ -1,9 +1,15 @@
<div class="row"> <div class="row">
<div class="col-sm-12">
@component('admin.components.info')
Subfleets are aircraft groups. The "type" is a short name. Airlines always
group aircraft together by feature, so 737s with winglets might have a type of
"B.738-WL". You can create as many as you want, you need at least one, though.
<div class="form-group col-sm-6"> Read more about subfleets <a
{{ Form::label('name', 'Name:') }} href="http://docs.phpvms.net/concepts/basics#subfleets-and-aircraft"
{{ Form::text('name', null, ['class' => 'form-control']) }} target="_new">here</a>.
<p class="text-danger">{{ $errors->first('name') }}</p>
@endcomponent
</div> </div>
<div class="form-group col-sm-6"> <div class="form-group col-sm-6">
@ -11,6 +17,13 @@
{{ Form::text('type', null, ['class' => 'form-control']) }} {{ Form::text('type', null, ['class' => 'form-control']) }}
<p class="text-danger">{{ $errors->first('type') }}</p> <p class="text-danger">{{ $errors->first('type') }}</p>
</div> </div>
<div class="form-group col-sm-6">
{{ Form::label('name', 'Name:') }}
{{ Form::text('name', null, ['class' => 'form-control']) }}
<p class="text-danger">{{ $errors->first('name') }}</p>
</div>
</div> </div>
<div class="row"> <div class="row">

View File

@ -4,7 +4,7 @@
@section('actions') @section('actions')
<li><a href="{{ route('admin.subfleets.export') }}"><i class="ti-plus"></i>Export to CSV</a> <li><a href="{{ route('admin.subfleets.export') }}"><i class="ti-plus"></i>Export to CSV</a>
<li><a href="{{ route('admin.subfleets.import') }}"><i class="ti-plus"></i>Import from CSV</a></li> <li><a href="{{ route('admin.subfleets.import') }}"><i class="ti-plus"></i>Import from CSV</a></li>
<li><a href="{{ route('admin.subfleets.create') }}"><i class="ti-plus"></i>Add New</a></li> <li><a href="{{ route('admin.subfleets.create') }}"><i class="ti-plus"></i>Add New Subfleet</a></li>
@endsection @endsection
@section('content') @section('content')

View File

@ -4,19 +4,20 @@
<th>Name</th> <th>Name</th>
<th>Airline</th> <th>Airline</th>
<th>Type</th> <th>Type</th>
<th>Aircraft</th>
<th></th> <th></th>
</thead> </thead>
<tbody> <tbody>
@foreach($subfleets as $subfleet) @foreach($subfleets as $subfleet)
<tr> <tr>
<td> <td>
<a href="{{ route('admin.subfleets.edit', [$subfleet->id]) }}"> <a href="{{ route('admin.aircraft.index') }}?subfleet={{$subfleet->id}}">
{{ $subfleet->name }} {{ $subfleet->name }}
</a> </a>
</td> </td>
<td>{{ $subfleet->airline->name }}</td> <td>{{ $subfleet->airline->name }}</td>
<td>{{ $subfleet->type }}</td> <td>{{ $subfleet->type }}</td>
<td>{{ $subfleet->aircraft->count() }}</td>
<td class="text-right"> <td class="text-right">
{{ Form::open(['route' => ['admin.subfleets.destroy', $subfleet->id], 'method' => 'delete']) }} {{ Form::open(['route' => ['admin.subfleets.destroy', $subfleet->id], 'method' => 'delete']) }}