phpvms/app/Models/Fare.php

50 lines
892 B
PHP
Raw Normal View History

<?php
namespace App\Models;
use App\Interfaces\Model;
/**
* Class Fare
2018-03-03 07:29:11 +08:00
* @property integer capacity
* @property float cost
* @property float price
* @property mixed code
* @package App\Models
*/
class Fare extends Model
{
public $table = 'fares';
2018-03-21 08:40:19 +08:00
protected $fillable = [
'code',
'name',
'price',
'cost',
'capacity',
'notes',
'active',
];
protected $casts = [
'price' => 'float',
'cost' => 'float',
'capacity' => 'integer',
'active' => 'boolean',
];
public static $rules = [
2018-03-22 01:35:06 +08:00
'code' => 'required',
'name' => 'required',
];
/**
* any foreign keys
*/
public function subfleets()
{
2018-01-08 23:22:12 +08:00
return $this->belongsToMany(Subfleet::class, 'subfleet_fare')
->withPivot('price', 'cost', 'capacity');
}
}