Subfleet Hubs / Base Airports (#978)
* Update SubFleet Model Add hub_id for storing subfleet's main base/hub airport, define a relationship with airport model to get details of the base/hub airport when needed. * Update Admin / SubFleetController Added the ability to read and pass hub airports to admin view for create/edit options. * Update Admin/SubFleets.fields.blade Added the dropdown for adding/editing main base/hub of a subfleet. * Add migration for the hub_id column Co-authored-by: Nabeel S <nabeelio@users.noreply.github.com> Co-authored-by: Nabeel Shahzad <nshahzad@live.com>
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Contracts\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a hub to the subfleet is
|
||||||
|
*/
|
||||||
|
class AddHubToSubfleets extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('subfleets', function (Blueprint $table) {
|
||||||
|
$table->string('hub_id', 4)
|
||||||
|
->nullable()
|
||||||
|
->after('airline_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ use App\Http\Controllers\Admin\Traits\Importable;
|
|||||||
use App\Http\Requests\CreateSubfleetRequest;
|
use App\Http\Requests\CreateSubfleetRequest;
|
||||||
use App\Http\Requests\UpdateSubfleetRequest;
|
use App\Http\Requests\UpdateSubfleetRequest;
|
||||||
use App\Models\Airline;
|
use App\Models\Airline;
|
||||||
|
use App\Models\Airport;
|
||||||
use App\Models\Enums\FareType;
|
use App\Models\Enums\FareType;
|
||||||
use App\Models\Enums\FuelType;
|
use App\Models\Enums\FuelType;
|
||||||
use App\Models\Enums\ImportExportType;
|
use App\Models\Enums\ImportExportType;
|
||||||
@@ -133,6 +134,7 @@ class SubfleetController extends Controller
|
|||||||
{
|
{
|
||||||
return view('admin.subfleets.create', [
|
return view('admin.subfleets.create', [
|
||||||
'airlines' => Airline::all()->pluck('name', 'id'),
|
'airlines' => Airline::all()->pluck('name', 'id'),
|
||||||
|
'hubs' => Airport::where('hub', 1)->pluck('name', 'id'),
|
||||||
'fuel_types' => FuelType::labels(),
|
'fuel_types' => FuelType::labels(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -203,6 +205,7 @@ class SubfleetController extends Controller
|
|||||||
|
|
||||||
return view('admin.subfleets.edit', [
|
return view('admin.subfleets.edit', [
|
||||||
'airlines' => Airline::all()->pluck('name', 'id'),
|
'airlines' => Airline::all()->pluck('name', 'id'),
|
||||||
|
'hubs' => Airport::where('hub', 1)->pluck('name', 'id'),
|
||||||
'fuel_types' => FuelType::labels(),
|
'fuel_types' => FuelType::labels(),
|
||||||
'avail_fares' => $avail_fares,
|
'avail_fares' => $avail_fares,
|
||||||
'avail_ranks' => $avail_ranks,
|
'avail_ranks' => $avail_ranks,
|
||||||
|
|||||||
@@ -8,27 +8,26 @@ use App\Models\Traits\ExpensableTrait;
|
|||||||
use App\Models\Traits\FilesTrait;
|
use App\Models\Traits\FilesTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Subfleet
|
|
||||||
*
|
|
||||||
* @property int id
|
* @property int id
|
||||||
* @property string type
|
* @property string type
|
||||||
* @property string name
|
* @property string name
|
||||||
|
* @property int airline_id
|
||||||
|
* @property int hub_id
|
||||||
* @property string ground_handling_multiplier
|
* @property string ground_handling_multiplier
|
||||||
* @property Fare[] fares
|
* @property Fare[] fares
|
||||||
* @property float cost_block_hour
|
* @property float cost_block_hour
|
||||||
* @property float cost_delay_minute
|
* @property float cost_delay_minute
|
||||||
* @property Airline airline
|
* @property Airline airline
|
||||||
* @property int airline_id
|
* @property Airport hub
|
||||||
*/
|
*/
|
||||||
class Subfleet extends Model
|
class Subfleet extends Model
|
||||||
{
|
{
|
||||||
use ExpensableTrait;
|
use ExpensableTrait;
|
||||||
use FilesTrait;
|
use FilesTrait;
|
||||||
|
|
||||||
public $table = 'subfleets';
|
|
||||||
|
|
||||||
public $fillable = [
|
public $fillable = [
|
||||||
'airline_id',
|
'airline_id',
|
||||||
|
'hub_id',
|
||||||
'type',
|
'type',
|
||||||
'name',
|
'name',
|
||||||
'fuel_type',
|
'fuel_type',
|
||||||
@@ -40,6 +39,8 @@ class Subfleet extends Model
|
|||||||
'gross_weight',
|
'gross_weight',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public $table = 'subfleets';
|
||||||
|
|
||||||
public $casts = [
|
public $casts = [
|
||||||
'airline_id' => 'integer',
|
'airline_id' => 'integer',
|
||||||
'turn_time' => 'integer',
|
'turn_time' => 'integer',
|
||||||
@@ -55,6 +56,7 @@ class Subfleet extends Model
|
|||||||
public static $rules = [
|
public static $rules = [
|
||||||
'type' => 'required',
|
'type' => 'required',
|
||||||
'name' => 'required',
|
'name' => 'required',
|
||||||
|
'hub_id' => 'nullable',
|
||||||
'ground_handling_multiplier' => 'nullable|numeric',
|
'ground_handling_multiplier' => 'nullable|numeric',
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -81,6 +83,11 @@ class Subfleet extends Model
|
|||||||
return $this->belongsTo(Airline::class, 'airline_id');
|
return $this->belongsTo(Airline::class, 'airline_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hub()
|
||||||
|
{
|
||||||
|
return $this->hasOne(Airport::class, 'id', 'hub_id');
|
||||||
|
}
|
||||||
|
|
||||||
public function fares()
|
public function fares()
|
||||||
{
|
{
|
||||||
return $this->belongsToMany(Fare::class, 'subfleet_fare')
|
return $this->belongsToMany(Fare::class, 'subfleet_fare')
|
||||||
|
|||||||
@@ -12,19 +12,25 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-sm-4">
|
<div class="form-group col-sm-3">
|
||||||
{{ Form::label('airline_id', 'Airline:') }}
|
{{ Form::label('airline_id', 'Airline:') }}
|
||||||
{{ Form::select('airline_id', $airlines, null , ['class' => 'form-control select2']) }}
|
{{ Form::select('airline_id', $airlines, null , ['class' => 'form-control select2']) }}
|
||||||
<p class="text-danger">{{ $errors->first('airline_id') }}</p>
|
<p class="text-danger">{{ $errors->first('airline_id') }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-sm-4">
|
<div class="form-group col-sm-3">
|
||||||
|
{{ Form::label('hub_id', 'Main 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('type', 'Type:') }}
|
{{ Form::label('type', 'Type:') }}
|
||||||
{{ Form::text('type', null, ['class' => 'form-control']) }}
|
{{ Form::text('type', null, ['class' => 'form-control']) }}
|
||||||
<p class="text-danger">{{ $errors->first('type') }}</p>
|
<p class="text-danger">{{ $errors->first('type') }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-sm-4">
|
<div class="form-group col-sm-3">
|
||||||
{{ Form::label('name', 'Name:') }}
|
{{ Form::label('name', 'Name:') }}
|
||||||
{{ Form::text('name', null, ['class' => 'form-control']) }}
|
{{ Form::text('name', null, ['class' => 'form-control']) }}
|
||||||
<p class="text-danger">{{ $errors->first('name') }}</p>
|
<p class="text-danger">{{ $errors->first('name') }}</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user