2017-06-09 09:37:51 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
2017-12-26 05:19:34 +08:00
|
|
|
class Aircraft extends BaseModel
|
2017-06-09 09:37:51 +08:00
|
|
|
{
|
|
|
|
public $table = 'aircraft';
|
2017-06-11 07:27:19 +08:00
|
|
|
|
2017-12-13 06:58:27 +08:00
|
|
|
public $fillable = [
|
|
|
|
'subfleet_id',
|
|
|
|
'airport_id',
|
|
|
|
'name',
|
2018-01-03 11:00:46 +08:00
|
|
|
'icao',
|
2017-12-13 06:58:27 +08:00
|
|
|
'registration',
|
|
|
|
'tail_number',
|
|
|
|
'active',
|
|
|
|
];
|
2017-06-09 09:37:51 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The attributes that should be casted to native types.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2017-12-13 06:58:27 +08:00
|
|
|
protected $casts = [
|
|
|
|
'active' => 'boolean',
|
|
|
|
];
|
2017-06-09 09:37:51 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Validation rules
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2017-12-13 06:58:27 +08:00
|
|
|
public static $rules = [
|
|
|
|
'name' => 'required',
|
|
|
|
];
|
2017-06-10 11:19:17 +08:00
|
|
|
|
2018-01-04 12:04:51 +08:00
|
|
|
/**
|
|
|
|
* Callbacks
|
|
|
|
*/
|
|
|
|
protected static function boot()
|
|
|
|
{
|
|
|
|
parent::boot();
|
2018-01-04 12:28:17 +08:00
|
|
|
static::creating(function (Aircraft $model) {
|
2018-01-04 12:04:51 +08:00
|
|
|
if (!empty($model->icao)) {
|
|
|
|
$model->icao = strtoupper(trim($model->icao));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-06-10 11:19:17 +08:00
|
|
|
/**
|
2017-06-23 09:55:45 +08:00
|
|
|
* foreign keys
|
2017-06-10 11:19:17 +08:00
|
|
|
*/
|
2017-06-29 08:56:10 +08:00
|
|
|
|
2017-06-25 03:00:56 +08:00
|
|
|
public function airport()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('App\Models\Airport', 'airport_id');
|
|
|
|
}
|
2017-06-10 14:50:00 +08:00
|
|
|
|
2017-06-23 09:55:45 +08:00
|
|
|
public function subfleet()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('App\Models\Subfleet', 'subfleet_id');
|
2017-06-10 14:50:00 +08:00
|
|
|
}
|
2017-06-09 09:37:51 +08:00
|
|
|
}
|