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.
* @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')
]);
}

View File

@ -1,7 +1,11 @@
<div class="row">
<div class="form-group col-sm-6">
{{ 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>
</div>

View File

@ -4,8 +4,9 @@
@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.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="{{ route('admin.aircraft.create') }}"><i class="ti-plus"></i>New Aircraft</a></li>
{{--<li><a href="{{ url('/admin/subfleets') }}"><i class="ti-files"></i>Subfleets</a></li>--}}
<li><a href="{{ route('admin.aircraft.create') }}?subfleet={{$subfleet_id}}">
<i class="ti-plus"></i>New Aircraft</a></li>
@endsection
@section('content')

View File

@ -16,7 +16,7 @@
</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/finances') }}"><i class="pe-7s-display1"></i>finances</a></li>
</ul>
@ -31,9 +31,9 @@
<div class="collapse" id="config_menu" aria-expanded="true">
<ul class="nav">
<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
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/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>

View File

@ -1,9 +1,15 @@
<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">
{{ Form::label('name', 'Name:') }}
{{ Form::text('name', null, ['class' => 'form-control']) }}
<p class="text-danger">{{ $errors->first('name') }}</p>
Read more about subfleets <a
href="http://docs.phpvms.net/concepts/basics#subfleets-and-aircraft"
target="_new">here</a>.
@endcomponent
</div>
<div class="form-group col-sm-6">
@ -11,6 +17,13 @@
{{ Form::text('type', null, ['class' => 'form-control']) }}
<p class="text-danger">{{ $errors->first('type') }}</p>
</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 class="row">

View File

@ -4,7 +4,7 @@
@section('actions')
<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.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
@section('content')

View File

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