set fare classes on aircraft w/ overrides (no admin ui yet)
This commit is contained in:
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Class Aircraft
|
||||
*
|
||||
* @package App\Models
|
||||
* @version June 9, 2017, 1:06 am UTC
|
||||
*/
|
||||
@@ -15,42 +16,46 @@ class Aircraft extends Model
|
||||
use SoftDeletes;
|
||||
|
||||
public $table = 'aircraft';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public $fillable = [
|
||||
'aircraft_class_id',
|
||||
'icao',
|
||||
'name',
|
||||
'full_name',
|
||||
'registration',
|
||||
'active'
|
||||
];
|
||||
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',
|
||||
];
|
||||
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'
|
||||
];
|
||||
public static $rules
|
||||
= [
|
||||
'icao' => 'required|max:4',
|
||||
'name' => 'required',
|
||||
'full_name' => 'required',
|
||||
'registration' => 'required',
|
||||
'active' => 'default:1',
|
||||
];
|
||||
|
||||
/**
|
||||
* foreign key
|
||||
@@ -63,8 +68,12 @@ class Aircraft extends Model
|
||||
);
|
||||
}
|
||||
|
||||
public function fares() {
|
||||
# aircraft_fare == table name
|
||||
return $this->belongsToMany('App\Models\Fare', 'aircraft_fare');
|
||||
public function fares()
|
||||
{
|
||||
$r = $this->belongsToMany(
|
||||
'App\Models\Fare',
|
||||
'aircraft_fare'
|
||||
)->withPivot('price', 'cost', 'capacity');
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user