2017-06-23 09:55:45 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class Subfleet
|
|
|
|
* @package App\Models
|
|
|
|
*/
|
2017-12-26 05:19:34 +08:00
|
|
|
class Subfleet extends BaseModel
|
2017-06-23 09:55:45 +08:00
|
|
|
{
|
|
|
|
public $table = 'subfleets';
|
|
|
|
protected $dates = ['deleted_at'];
|
|
|
|
|
|
|
|
public $fillable = [
|
|
|
|
'airline_id',
|
|
|
|
'name',
|
2017-07-05 22:55:36 +08:00
|
|
|
'type',
|
|
|
|
'fuel_type',
|
2017-06-23 09:55:45 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The attributes that should be casted to native types.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $casts = [
|
|
|
|
'airline_id' => 'integer',
|
2017-07-05 22:55:36 +08:00
|
|
|
'fuel_type' => 'integer',
|
2017-12-13 03:26:08 +08:00
|
|
|
'cargo_capacity' => 'double',
|
|
|
|
'fuel_capacity' => 'double',
|
|
|
|
'gross_weight' => 'double',
|
2017-06-23 09:55:45 +08:00
|
|
|
];
|
|
|
|
|
2017-12-31 04:37:10 +08:00
|
|
|
public static $rules = [
|
|
|
|
'name' => 'required',
|
|
|
|
'type' => 'required',
|
|
|
|
];
|
|
|
|
|
2017-12-13 06:58:27 +08:00
|
|
|
public function aircraft()
|
|
|
|
{
|
|
|
|
return $this->hasMany('App\Models\Aircraft', 'subfleet_id');
|
|
|
|
}
|
|
|
|
|
2017-06-23 09:55:45 +08:00
|
|
|
public function airline()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('App\Models\Airline', 'airline_id');
|
|
|
|
}
|
|
|
|
|
2017-06-25 00:09:27 +08:00
|
|
|
public function fares()
|
|
|
|
{
|
|
|
|
return $this->belongsToMany(
|
|
|
|
'App\Models\Fare',
|
|
|
|
'subfleet_fare'
|
|
|
|
)->withPivot('price', 'cost', 'capacity');
|
|
|
|
}
|
|
|
|
|
2017-06-24 06:33:18 +08:00
|
|
|
public function flights()
|
|
|
|
{
|
|
|
|
return $this->belongsToMany('App\Models\Flight', 'subfleet_flight');
|
|
|
|
}
|
|
|
|
|
2017-06-23 09:55:45 +08:00
|
|
|
public function ranks()
|
|
|
|
{
|
|
|
|
return $this->belongsToMany(
|
|
|
|
'App\Models\Ranks',
|
|
|
|
'subfleet_rank'
|
|
|
|
)->withPivot('acars_pay', 'manual_pay');
|
|
|
|
}
|
|
|
|
}
|