Skip to content

Commit

Permalink
Load subfleet page first, can add aircraft from there #217
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeelio committed Mar 24, 2018
1 parent 1eb7e5d commit 0671742
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 18 deletions.
22 changes: 17 additions & 5 deletions app/Http/Controllers/Admin/AircraftController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
]);
}

Expand Down
6 changes: 5 additions & 1 deletion resources/views/admin/aircraft/fields.blade.php
Original file line number Diff line number Diff line change
@@ -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>

Expand Down
5 changes: 3 additions & 2 deletions resources/views/admin/aircraft/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
6 changes: 3 additions & 3 deletions resources/views/admin/menu.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class="badge bg-light-blue pull-right">3</span>
</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>
Expand All @@ -31,9 +31,9 @@ class="badge bg-light-blue pull-right">3</span>
<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>
Expand Down
21 changes: 17 additions & 4 deletions resources/views/admin/subfleets/fields.blade.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
<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">
{{ Form::label('type', 'Type:') }}
{{ 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">

Expand Down
2 changes: 1 addition & 1 deletion resources/views/admin/subfleets/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
5 changes: 3 additions & 2 deletions resources/views/admin/subfleets/table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']) }}

Expand Down

0 comments on commit 0671742

Please sign in to comment.