2017-06-09 09:37:51 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Eloquent as Model;
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class Aircraft
|
2017-06-11 07:27:19 +08:00
|
|
|
*
|
2017-06-09 09:37:51 +08:00
|
|
|
* @package App\Models
|
|
|
|
* @version June 9, 2017, 1:06 am UTC
|
|
|
|
*/
|
|
|
|
class Aircraft extends Model
|
|
|
|
{
|
|
|
|
use SoftDeletes;
|
|
|
|
|
|
|
|
public $table = 'aircraft';
|
2017-06-11 07:27:19 +08:00
|
|
|
|
2017-06-09 09:37:51 +08:00
|
|
|
protected $dates = ['deleted_at'];
|
|
|
|
|
2017-06-11 07:27:19 +08:00
|
|
|
public $fillable
|
|
|
|
= [
|
|
|
|
'aircraft_class_id',
|
|
|
|
'icao',
|
|
|
|
'name',
|
|
|
|
'registration',
|
2017-06-12 04:37:57 +08:00
|
|
|
'tail_number',
|
2017-06-11 07:27:19 +08:00
|
|
|
'active',
|
|
|
|
];
|
2017-06-09 09:37:51 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The attributes that should be casted to native types.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2017-06-11 07:27:19 +08:00
|
|
|
protected $casts
|
|
|
|
= [
|
|
|
|
'icao' => 'string',
|
|
|
|
'name' => 'string',
|
|
|
|
'registration' => 'string',
|
|
|
|
'active' => 'boolean',
|
|
|
|
];
|
2017-06-09 09:37:51 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Validation rules
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2017-06-11 07:27:19 +08:00
|
|
|
public static $rules
|
|
|
|
= [
|
2017-06-12 04:37:57 +08:00
|
|
|
'icao' => 'required|max:5',
|
2017-06-11 07:27:19 +08:00
|
|
|
'name' => 'required',
|
2017-06-12 04:37:57 +08:00
|
|
|
'active' => '',
|
2017-06-11 07:27:19 +08:00
|
|
|
];
|
2017-06-10 11:19:17 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* foreign key
|
|
|
|
*/
|
|
|
|
public function class()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(
|
|
|
|
'App\Models\AircraftClass',
|
|
|
|
'aircraft_class_id'
|
|
|
|
);
|
|
|
|
}
|
2017-06-10 14:50:00 +08:00
|
|
|
|
2017-06-11 07:27:19 +08:00
|
|
|
public function fares()
|
|
|
|
{
|
|
|
|
$r = $this->belongsToMany(
|
|
|
|
'App\Models\Fare',
|
|
|
|
'aircraft_fare'
|
|
|
|
)->withPivot('price', 'cost', 'capacity');
|
|
|
|
return $r;
|
2017-06-10 14:50:00 +08:00
|
|
|
}
|
2017-06-09 09:37:51 +08:00
|
|
|
}
|