2017-06-18 06:25:36 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Eloquent as Model;
|
|
|
|
|
2017-12-13 02:43:58 +08:00
|
|
|
use App\Models\Traits\HashId;
|
2017-08-13 01:24:00 +08:00
|
|
|
|
2017-06-18 06:25:36 +08:00
|
|
|
class Flight extends Model
|
|
|
|
{
|
2017-12-13 02:43:58 +08:00
|
|
|
use HashId;
|
2017-06-25 02:20:24 +08:00
|
|
|
|
2017-06-18 06:25:36 +08:00
|
|
|
public $table = 'flights';
|
2017-06-25 02:20:24 +08:00
|
|
|
public $incrementing = false;
|
2017-06-18 06:25:36 +08:00
|
|
|
|
|
|
|
protected $dates = ['deleted_at'];
|
|
|
|
|
2017-12-13 03:59:05 +08:00
|
|
|
public $fillable = [
|
|
|
|
'airline_id',
|
|
|
|
'flight_number',
|
|
|
|
'route_code',
|
|
|
|
'route_leg',
|
|
|
|
'dpt_airport_id',
|
|
|
|
'arr_airport_id',
|
|
|
|
'alt_airport_id',
|
|
|
|
'route',
|
|
|
|
'dpt_time',
|
|
|
|
'arr_time',
|
|
|
|
'notes',
|
|
|
|
'has_bid',
|
|
|
|
'active',
|
|
|
|
];
|
2017-06-18 06:25:36 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The attributes that should be casted to native types.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2017-12-13 03:59:05 +08:00
|
|
|
protected $casts = [
|
|
|
|
'flight_number' => 'integer',
|
|
|
|
'route_code' => 'string',
|
|
|
|
'route_leg' => 'string',
|
|
|
|
'route' => 'string',
|
|
|
|
'dpt_time' => 'string',
|
|
|
|
'arr_time' => 'string',
|
|
|
|
'notes' => 'string',
|
|
|
|
'has_bid' => 'boolean',
|
|
|
|
'active' => 'boolean',
|
|
|
|
];
|
2017-06-18 06:25:36 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Validation rules
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2017-12-13 03:59:05 +08:00
|
|
|
public static $rules = [
|
|
|
|
'flight_number' => 'required',
|
|
|
|
'dpt_airport_id' => 'required',
|
|
|
|
'arr_airport_id' => 'required',
|
|
|
|
];
|
2017-06-18 06:25:36 +08:00
|
|
|
|
2017-12-13 06:58:27 +08:00
|
|
|
public function getFlightIdIataAttribute($value)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-07-11 08:06:06 +08:00
|
|
|
/**
|
|
|
|
* Relationship
|
|
|
|
*/
|
|
|
|
|
2017-06-20 00:50:25 +08:00
|
|
|
public function airline()
|
|
|
|
{
|
2017-06-24 06:38:32 +08:00
|
|
|
return $this->belongsTo('App\Models\Airline', 'airline_id');
|
2017-06-20 00:50:25 +08:00
|
|
|
}
|
|
|
|
|
2017-06-18 06:25:36 +08:00
|
|
|
public function dpt_airport()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('App\Models\Airport', 'dpt_airport_id');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function arr_airport()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('App\Models\Airport', 'arr_airport_id');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function alt_airport()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('App\Models\Airport', 'alt_airport_id');
|
|
|
|
}
|
|
|
|
|
2017-07-11 08:06:06 +08:00
|
|
|
public function fields()
|
|
|
|
{
|
|
|
|
return $this->hasMany('App\Models\FlightFields', 'flight_id');
|
|
|
|
}
|
|
|
|
|
2017-06-24 06:33:18 +08:00
|
|
|
public function subfleets()
|
2017-06-18 06:25:36 +08:00
|
|
|
{
|
2017-06-24 06:33:18 +08:00
|
|
|
return $this->belongsToMany('App\Models\Subfleet', 'subfleet_flight');
|
2017-06-18 06:25:36 +08:00
|
|
|
}
|
|
|
|
}
|