phpvms/app/Models/Aircraft.php
2017-06-10 01:50:00 -05:00

71 lines
1.3 KiB
PHP

<?php
namespace App\Models;
use Eloquent as Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class Aircraft
* @package App\Models
* @version June 9, 2017, 1:06 am UTC
*/
class Aircraft extends Model
{
use SoftDeletes;
public $table = 'aircraft';
protected $dates = ['deleted_at'];
public $fillable = [
'aircraft_class_id',
'icao',
'name',
'full_name',
'registration',
'active'
];
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts = [
'icao' => 'string',
'name' => 'string',
'full_name' => 'string',
'registration' => 'string',
'active' => 'boolean',
];
/**
* Validation rules
*
* @var array
*/
public static $rules = [
'icao' => 'required|max:4',
'name' => 'required',
'full_name' => 'required',
'registration' => 'required',
'active' => 'default:1'
];
/**
* foreign key
*/
public function class()
{
return $this->belongsTo(
'App\Models\AircraftClass',
'aircraft_class_id'
);
}
public function fares() {
# aircraft_fare == table name
return $this->belongsToMany('App\Models\Fare', 'aircraft_fare');
}
}