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:
parent
4d21ca0982
commit
c45d52dffa
@ -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');
|
||||
});
|
||||
}
|
||||
}
|
@ -79,6 +79,7 @@ class AircraftController extends Controller
|
||||
{
|
||||
return view('admin.aircraft.create', [
|
||||
'airports' => $this->airportRepo->selectBoxList(),
|
||||
'hubs' => $this->airportRepo->selectBoxList(true, true),
|
||||
'subfleets' => Subfleet::all()->pluck('name', 'id'),
|
||||
'statuses' => AircraftStatus::select(false),
|
||||
'subfleet_id' => $request->query('subfleet'),
|
||||
@ -143,6 +144,7 @@ class AircraftController extends Controller
|
||||
return view('admin.aircraft.edit', [
|
||||
'aircraft' => $aircraft,
|
||||
'airports' => $this->airportRepo->selectBoxList(),
|
||||
'hubs' => $this->airportRepo->selectBoxList(true, true),
|
||||
'subfleets' => Subfleet::all()->pluck('name', 'id'),
|
||||
'statuses' => AircraftStatus::select(false),
|
||||
]);
|
||||
|
@ -13,6 +13,7 @@ use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
* @property int id
|
||||
* @property mixed subfleet_id
|
||||
* @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 name
|
||||
* @property string icao
|
||||
@ -22,6 +23,7 @@ use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
* @property float zfw
|
||||
* @property string hex_code
|
||||
* @property Airport airport
|
||||
* @property Airport hub
|
||||
* @property Subfleet subfleet
|
||||
* @property int status
|
||||
* @property int state
|
||||
@ -39,6 +41,7 @@ class Aircraft extends Model
|
||||
protected $fillable = [
|
||||
'subfleet_id',
|
||||
'airport_id',
|
||||
'hub_id',
|
||||
'iata',
|
||||
'icao',
|
||||
'name',
|
||||
@ -127,6 +130,11 @@ class Aircraft extends Model
|
||||
return $this->belongsTo(Airport::class, 'airport_id');
|
||||
}
|
||||
|
||||
public function hub()
|
||||
{
|
||||
return $this->hasOne(Airport::class, 'id', 'hub_id');
|
||||
}
|
||||
|
||||
public function pireps()
|
||||
{
|
||||
return $this->hasMany(Pirep::class, 'aircraft_id');
|
||||
|
@ -25,6 +25,7 @@ class AircraftImporter extends ImportExport
|
||||
'subfleet' => 'required',
|
||||
'iata' => 'nullable',
|
||||
'icao' => 'nullable',
|
||||
'hub_id' => 'nullable',
|
||||
'airport_id' => 'nullable',
|
||||
'name' => '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 int $index
|
||||
|
@ -5,7 +5,7 @@
|
||||
Subfleet and Status
|
||||
</h6>
|
||||
<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::select('subfleet_id', $subfleets, $subfleet_id ?? null, [
|
||||
'class' => 'form-control select2',
|
||||
@ -15,17 +15,21 @@
|
||||
<p class="text-danger">{{ $errors->first('subfleet_id') }}</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-sm-4">
|
||||
<div class="form-group col-sm-3">
|
||||
{{ Form::label('status', 'Status:') }}
|
||||
{{ Form::select('status', $statuses, null, ['class' => 'form-control select2', 'placeholder' => 'Select Status']) }}
|
||||
<p class="text-danger">{{ $errors->first('subfleet_id') }}</p>
|
||||
</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::select('airport_id', $airports, null, [
|
||||
'class' => 'form-control select2'
|
||||
]) }}
|
||||
{{ Form::select('airport_id', $airports, null, ['class' => 'form-control select2']) }}
|
||||
<p class="text-danger">{{ $errors->first('airport_id') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -3,6 +3,7 @@
|
||||
<th>Name</th>
|
||||
<th style="text-align: center;">Registration</th>
|
||||
<th>Subfleet</th>
|
||||
<th style="text-align: center;">Hub</th>
|
||||
<th style="text-align: center;">Location</th>
|
||||
<th style="text-align: center;">Hours</th>
|
||||
<th style="text-align: center;">Active</th>
|
||||
@ -22,6 +23,7 @@
|
||||
-
|
||||
@endif
|
||||
</td>
|
||||
<td style="text-align: center;">{{ $ac->hub_id }}</td>
|
||||
<td style="text-align: center;">{{ $ac->airport_id }}</td>
|
||||
<td style="text-align: center;">
|
||||
@minutestotime($ac->flight_time)
|
||||
|
@ -4,6 +4,7 @@
|
||||
<th>Name</th>
|
||||
<th>Airline</th>
|
||||
<th>Type</th>
|
||||
<th>Hub</th>
|
||||
<th>Aircraft</th>
|
||||
<th></th>
|
||||
</thead>
|
||||
@ -17,6 +18,7 @@
|
||||
</td>
|
||||
<td>{{ optional($subfleet->airline)->name }}</td>
|
||||
<td>{{ $subfleet->type }}</td>
|
||||
<td>{{ $subfleet->hub_id }}</td>
|
||||
<td>{{ $subfleet->aircraft->count() }}</td>
|
||||
<td class="text-right">
|
||||
{{ Form::open(['route' => ['admin.subfleets.destroy', $subfleet->id], 'method' => 'delete']) }}
|
||||
|
@ -1,3 +1,3 @@
|
||||
subfleet,iata, icao,airport_id, name,registration,hex_code,mtow,zfw,status
|
||||
A32X,A320,320,,A320-211,N309US,,,,S
|
||||
74X,747 400, ,,,
|
||||
subfleet,iata,icao,hub_id,airport_id,name,registration,hex_code,mtow,zfw,status
|
||||
A32X,A320,320,,,A320-211,N309US,,,,S
|
||||
74X,747 400,, ,,,
|
||||
|
|
@ -1,3 +1,3 @@
|
||||
subfleet,iata, icao,airport_id, name,registration,hex_code,mtow,zfw,status
|
||||
A32X,A320,320,,A320-211,N309US,,,,A
|
||||
74X,747 400,, ,,
|
||||
subfleet,iata,icao,hub_id,airport_id,name,registration,hex_code,mtow,zfw,status
|
||||
A32X,A320,320,,,A320-211,N309US,,,,A
|
||||
74X,747 400,,, ,,
|
||||
|
|
@ -1,3 +1,3 @@
|
||||
subfleet,iata, icao,airport_id, name,registration,hex_code,mtow,zfw,status
|
||||
A32X,A320-211,,N309US,,,
|
||||
, B744-GE,, N304,,,
|
||||
subfleet,iata,icao,hub_id,airport_id,name,registration,hex_code,mtow,zfw,status
|
||||
A32X,A320-211,,,N309US,,,
|
||||
, B744-GE,,, N304,,,
|
||||
|
|
Loading…
Reference in New Issue
Block a user