Aircraft level Hub definitions (#1363)

* Aircraft level Hub definitions

* Add ability to define a hub for an aircraft apart from its subfleet.

* Update csv import/export capability for hub_id field

* Fix importertest source csv

* Fix source csv for updating too

* Update aircraft_empty_cols.csv

Co-authored-by: Nabeel S <nabeelio@users.noreply.github.com>
This commit is contained in:
B.Fatih KOZ 2021-11-30 22:54:29 +03:00 committed by GitHub
parent 4d21ca0982
commit c45d52dffa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 50 additions and 16 deletions

View File

@ -0,0 +1,15 @@
<?php
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddHubToAircraft extends Migration
{
public function up()
{
Schema::table('aircraft', function (Blueprint $table) {
$table->string('hub_id', 5)->nullable()->after('airport_id');
});
}
}

View File

@ -79,6 +79,7 @@ class AircraftController extends Controller
{ {
return view('admin.aircraft.create', [ return view('admin.aircraft.create', [
'airports' => $this->airportRepo->selectBoxList(), 'airports' => $this->airportRepo->selectBoxList(),
'hubs' => $this->airportRepo->selectBoxList(true, true),
'subfleets' => Subfleet::all()->pluck('name', 'id'), 'subfleets' => Subfleet::all()->pluck('name', 'id'),
'statuses' => AircraftStatus::select(false), 'statuses' => AircraftStatus::select(false),
'subfleet_id' => $request->query('subfleet'), 'subfleet_id' => $request->query('subfleet'),
@ -143,6 +144,7 @@ class AircraftController extends Controller
return view('admin.aircraft.edit', [ return view('admin.aircraft.edit', [
'aircraft' => $aircraft, 'aircraft' => $aircraft,
'airports' => $this->airportRepo->selectBoxList(), 'airports' => $this->airportRepo->selectBoxList(),
'hubs' => $this->airportRepo->selectBoxList(true, true),
'subfleets' => Subfleet::all()->pluck('name', 'id'), 'subfleets' => Subfleet::all()->pluck('name', 'id'),
'statuses' => AircraftStatus::select(false), 'statuses' => AircraftStatus::select(false),
]); ]);

View File

@ -13,6 +13,7 @@ use Znck\Eloquent\Traits\BelongsToThrough;
* @property int id * @property int id
* @property mixed subfleet_id * @property mixed subfleet_id
* @property string airport_id The apt where the aircraft is * @property string airport_id The apt where the aircraft is
* @property string hub_id The apt where the aircraft is based
* @property string ident * @property string ident
* @property string name * @property string name
* @property string icao * @property string icao
@ -22,6 +23,7 @@ use Znck\Eloquent\Traits\BelongsToThrough;
* @property float zfw * @property float zfw
* @property string hex_code * @property string hex_code
* @property Airport airport * @property Airport airport
* @property Airport hub
* @property Subfleet subfleet * @property Subfleet subfleet
* @property int status * @property int status
* @property int state * @property int state
@ -39,6 +41,7 @@ class Aircraft extends Model
protected $fillable = [ protected $fillable = [
'subfleet_id', 'subfleet_id',
'airport_id', 'airport_id',
'hub_id',
'iata', 'iata',
'icao', 'icao',
'name', 'name',
@ -127,6 +130,11 @@ class Aircraft extends Model
return $this->belongsTo(Airport::class, 'airport_id'); return $this->belongsTo(Airport::class, 'airport_id');
} }
public function hub()
{
return $this->hasOne(Airport::class, 'id', 'hub_id');
}
public function pireps() public function pireps()
{ {
return $this->hasMany(Pirep::class, 'aircraft_id'); return $this->hasMany(Pirep::class, 'aircraft_id');

View File

@ -25,6 +25,7 @@ class AircraftImporter extends ImportExport
'subfleet' => 'required', 'subfleet' => 'required',
'iata' => 'nullable', 'iata' => 'nullable',
'icao' => 'nullable', 'icao' => 'nullable',
'hub_id' => 'nullable',
'airport_id' => 'nullable', 'airport_id' => 'nullable',
'name' => 'required', 'name' => 'required',
'registration' => 'required', 'registration' => 'required',
@ -53,7 +54,7 @@ class AircraftImporter extends ImportExport
} }
/** /**
* Import a flight, parse out the different rows * Import an aircraft, parse out the different rows
* *
* @param array $row * @param array $row
* @param int $index * @param int $index

View File

@ -5,7 +5,7 @@
&nbsp;Subfleet and Status &nbsp;Subfleet and Status
</h6> </h6>
<div class="form-container-body row"> <div class="form-container-body row">
<div class="form-group col-sm-4"> <div class="form-group col-sm-3">
{{ Form::label('subfleet_id', 'Subfleet:') }} {{ Form::label('subfleet_id', 'Subfleet:') }}
{{ Form::select('subfleet_id', $subfleets, $subfleet_id ?? null, [ {{ Form::select('subfleet_id', $subfleets, $subfleet_id ?? null, [
'class' => 'form-control select2', 'class' => 'form-control select2',
@ -15,17 +15,21 @@
<p class="text-danger">{{ $errors->first('subfleet_id') }}</p> <p class="text-danger">{{ $errors->first('subfleet_id') }}</p>
</div> </div>
<div class="form-group col-sm-4"> <div class="form-group col-sm-3">
{{ Form::label('status', 'Status:') }} {{ Form::label('status', 'Status:') }}
{{ Form::select('status', $statuses, null, ['class' => 'form-control select2', 'placeholder' => 'Select Status']) }} {{ Form::select('status', $statuses, null, ['class' => 'form-control select2', 'placeholder' => 'Select Status']) }}
<p class="text-danger">{{ $errors->first('subfleet_id') }}</p> <p class="text-danger">{{ $errors->first('subfleet_id') }}</p>
</div> </div>
<div class="form-group col-sm-4"> <div class="form-group col-sm-3">
{{ Form::label('hub_id', 'Hub:') }}
{{ Form::select('hub_id', $hubs, null, ['class' => 'form-control select2']) }}
<p class="text-danger">{{ $errors->first('hub_id') }}</p>
</div>
<div class="form-group col-sm-3">
{{ Form::label('airport_id', 'Location:') }} {{ Form::label('airport_id', 'Location:') }}
{{ Form::select('airport_id', $airports, null, [ {{ Form::select('airport_id', $airports, null, ['class' => 'form-control select2']) }}
'class' => 'form-control select2'
]) }}
<p class="text-danger">{{ $errors->first('airport_id') }}</p> <p class="text-danger">{{ $errors->first('airport_id') }}</p>
</div> </div>
</div> </div>

View File

@ -3,6 +3,7 @@
<th>Name</th> <th>Name</th>
<th style="text-align: center;">Registration</th> <th style="text-align: center;">Registration</th>
<th>Subfleet</th> <th>Subfleet</th>
<th style="text-align: center;">Hub</th>
<th style="text-align: center;">Location</th> <th style="text-align: center;">Location</th>
<th style="text-align: center;">Hours</th> <th style="text-align: center;">Hours</th>
<th style="text-align: center;">Active</th> <th style="text-align: center;">Active</th>
@ -22,6 +23,7 @@
- -
@endif @endif
</td> </td>
<td style="text-align: center;">{{ $ac->hub_id }}</td>
<td style="text-align: center;">{{ $ac->airport_id }}</td> <td style="text-align: center;">{{ $ac->airport_id }}</td>
<td style="text-align: center;"> <td style="text-align: center;">
@minutestotime($ac->flight_time) @minutestotime($ac->flight_time)

View File

@ -4,6 +4,7 @@
<th>Name</th> <th>Name</th>
<th>Airline</th> <th>Airline</th>
<th>Type</th> <th>Type</th>
<th>Hub</th>
<th>Aircraft</th> <th>Aircraft</th>
<th></th> <th></th>
</thead> </thead>
@ -17,6 +18,7 @@
</td> </td>
<td>{{ optional($subfleet->airline)->name }}</td> <td>{{ optional($subfleet->airline)->name }}</td>
<td>{{ $subfleet->type }}</td> <td>{{ $subfleet->type }}</td>
<td>{{ $subfleet->hub_id }}</td>
<td>{{ $subfleet->aircraft->count() }}</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']) }}

View File

@ -1,3 +1,3 @@
subfleet,iata, icao,airport_id, name,registration,hex_code,mtow,zfw,status subfleet,iata,icao,hub_id,airport_id,name,registration,hex_code,mtow,zfw,status
A32X,A320,320,,A320-211,N309US,,,,S A32X,A320,320,,,A320-211,N309US,,,,S
74X,747 400, ,,, 74X,747 400,, ,,,

1 subfleet,iata, icao,airport_id, name,registration,hex_code,mtow,zfw,status subfleet,iata,icao,hub_id,airport_id,name,registration,hex_code,mtow,zfw,status
2 A32X,A320,320,,A320-211,N309US,,,,S A32X,A320,320,,,A320-211,N309US,,,,S
3 74X,747 400, ,,, 74X,747 400,, ,,,

View File

@ -1,3 +1,3 @@
subfleet,iata, icao,airport_id, name,registration,hex_code,mtow,zfw,status subfleet,iata,icao,hub_id,airport_id,name,registration,hex_code,mtow,zfw,status
A32X,A320,320,,A320-211,N309US,,,,A A32X,A320,320,,,A320-211,N309US,,,,A
74X,747 400,, ,, 74X,747 400,,, ,,

1 subfleet,iata, icao,airport_id, name,registration,hex_code,mtow,zfw,status subfleet,iata,icao,hub_id,airport_id,name,registration,hex_code,mtow,zfw,status
2 A32X,A320,320,,A320-211,N309US,,,,A A32X,A320,320,,,A320-211,N309US,,,,A
3 74X,747 400,, ,, 74X,747 400,,, ,,

View File

@ -1,3 +1,3 @@
subfleet,iata, icao,airport_id, name,registration,hex_code,mtow,zfw,status subfleet,iata,icao,hub_id,airport_id,name,registration,hex_code,mtow,zfw,status
A32X,A320-211,,N309US,,, A32X,A320-211,,,N309US,,,
, B744-GE,, N304,,, , B744-GE,,, N304,,,

1 subfleet,iata, icao,airport_id, name,registration,hex_code,mtow,zfw,status subfleet,iata,icao,hub_id,airport_id,name,registration,hex_code,mtow,zfw,status
2 A32X,A320-211,,N309US,,, A32X,A320-211,,,N309US,,,
3 , B744-GE,, N304,,, , B744-GE,,, N304,,,