phpvms/app/Models/Aircraft.php

77 lines
1.4 KiB
PHP
Raw Normal View History

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-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-09 09:37:51 +08:00
protected $dates = ['deleted_at'];
public $fillable
= [
'aircraft_class_id',
'icao',
'name',
'registration',
'tail_number',
'active',
];
2017-06-09 09:37:51 +08:00
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts
= [
'icao' => 'string',
'name' => 'string',
'registration' => 'string',
'active' => 'boolean',
];
2017-06-09 09:37:51 +08:00
/**
* Validation rules
*
* @var array
*/
public static $rules
= [
'icao' => 'required|max:5',
'name' => 'required',
'active' => '',
];
/**
* foreign key
*/
public function class()
{
return $this->belongsTo(
'App\Models\AircraftClass',
'aircraft_class_id'
);
}
2017-06-10 14:50:00 +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
}