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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user