set fare classes on aircraft w/ overrides (no admin ui yet)

This commit is contained in:
Nabeel Shahzad
2017-06-10 18:27:19 -05:00
parent dee3503ad6
commit bf910e4549
27 changed files with 859 additions and 88 deletions

66
app/Models/Fare.php Normal file
View File

@@ -0,0 +1,66 @@
<?php
namespace App\Models;
use Eloquent as Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class Fare
*
* @package App\Models
* @version June 10, 2017, 4:03 am UTC
*/
class Fare extends Model
{
use SoftDeletes;
public $table = 'fares';
protected $dates = ['deleted_at'];
public $fillable
= [
'code',
'name',
'price',
'cost',
'notes',
'active',
];
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts
= [
'code' => 'string',
'name' => 'string',
'price' => 'float',
'cost' => 'float',
'notes' => 'string',
'active' => 'boolean',
];
/**
* Validation rules
*
* @var array
*/
public static $rules
= [
'code' => 'required',
'name' => 'required',
'cost' => 'default:0.0',
];
public function aircraft() {
return $this->belongsToMany(
'App\Models\Aircraft',
'aircraft_fare'
)->withPivot('price', 'cost', 'capacity');
}
}