phpvms/app/Models/Subfleet.php
B.Fatih KOZ e3b4a0ed2e
SimBrief integration enhancements (#1045)
* SimBrief Integration Update

* Added SimBrief Type field to subfleets, can be used to assign simbrief airframes to subfleets and fix non existing or wrong types. If not used simbrief form will use aircraft's icao type code

* Added Passenger and Baggage weights to settings

* Added setting for using PhpVms Pilot/User  Ident as simbrief atc callsign

* SimBrief form code cleaned up a bit and improved. Now form supports both cargo and passenger fares to be used at the same time.

Generated passenger baggage weight will be reduced from aircraft's cargo capacity and remaining amount will be used for random cargo generation.

Also multiple cargo fares or any mix is possible now (like only cargo, only passenger, multiple cargo and passenger fares)

* StyleFix (SimBrief Controller)

* Fix Callsign Setting Check

* Code Cleanup

Reduced loops and removed if's in loops, getting fares from aircraft instead of flight/subfleets.

No need to go through getReconciledFaresForFlight anymore. Aircraft provides all fare info we need.

Removed unnecessary html elements, added some comments.

* Update Simbrief Controller

Fixed setting checks.

Removed non used $subfleet and from main form and $aircraft from aircraft selection form blade.

Added/fixed comments.

* StyleFix for Controller
2021-02-24 09:32:29 -05:00

110 lines
2.7 KiB
PHP

<?php
namespace App\Models;
use App\Contracts\Model;
use App\Models\Enums\AircraftStatus;
use App\Models\Traits\ExpensableTrait;
use App\Models\Traits\FilesTrait;
/**
* @property int id
* @property string type
* @property string simbrief_type
* @property string name
* @property int airline_id
* @property int hub_id
* @property string ground_handling_multiplier
* @property Fare[] fares
* @property float cost_block_hour
* @property float cost_delay_minute
* @property Airline airline
* @property Airport hub
*/
class Subfleet extends Model
{
use ExpensableTrait;
use FilesTrait;
public $fillable = [
'airline_id',
'hub_id',
'type',
'simbrief_type',
'name',
'fuel_type',
'cost_block_hour',
'cost_delay_minute',
'ground_handling_multiplier',
'cargo_capacity',
'fuel_capacity',
'gross_weight',
];
public $table = 'subfleets';
public $casts = [
'airline_id' => 'integer',
'turn_time' => 'integer',
'cost_block_hour' => 'float',
'cost_delay_minute' => 'float',
'fuel_type' => 'integer',
'ground_handling_multiplier' => 'float',
'cargo_capacity' => 'float',
'fuel_capacity' => 'float',
'gross_weight' => 'float',
];
public static $rules = [
'type' => 'required',
'name' => 'required',
'hub_id' => 'nullable',
'ground_handling_multiplier' => 'nullable|numeric',
];
/**
* @param $type
*/
public function setTypeAttribute($type)
{
$type = str_replace([' ', ','], ['-', ''], $type);
$this->attributes['type'] = $type;
}
/**
* Relationships
*/
public function aircraft()
{
return $this->hasMany(Aircraft::class, 'subfleet_id')
->where('status', AircraftStatus::ACTIVE);
}
public function airline()
{
return $this->belongsTo(Airline::class, 'airline_id');
}
public function hub()
{
return $this->hasOne(Airport::class, 'id', 'hub_id');
}
public function fares()
{
return $this->belongsToMany(Fare::class, 'subfleet_fare')
->withPivot('price', 'cost', 'capacity');
}
public function flights()
{
return $this->belongsToMany(Flight::class, 'flight_subfleet');
}
public function ranks()
{
return $this->belongsToMany(Rank::class, 'subfleet_rank')
->withPivot('acars_pay', 'manual_pay');
}
}