2017-06-11 07:27:19 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
2018-08-27 00:40:04 +08:00
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
use App\Interfaces\Model;
|
2017-06-11 07:27:19 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class Fare
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
|
|
|
* @property int capacity
|
2018-03-20 09:50:40 +08:00
|
|
|
* @property float cost
|
|
|
|
* @property float price
|
|
|
|
* @property mixed code
|
2018-03-30 03:55:25 +08:00
|
|
|
* @property mixed count Only when merged with pivot
|
2017-06-11 07:27:19 +08:00
|
|
|
*/
|
2018-03-20 09:50:40 +08:00
|
|
|
class Fare extends Model
|
2017-06-11 07:27:19 +08:00
|
|
|
{
|
|
|
|
public $table = 'fares';
|
|
|
|
|
2018-03-21 08:40:19 +08:00
|
|
|
protected $fillable = [
|
2017-12-14 01:29:14 +08:00
|
|
|
'code',
|
|
|
|
'name',
|
|
|
|
'price',
|
|
|
|
'cost',
|
|
|
|
'capacity',
|
|
|
|
'notes',
|
|
|
|
'active',
|
|
|
|
];
|
|
|
|
|
|
|
|
protected $casts = [
|
2018-03-20 09:50:40 +08:00
|
|
|
'price' => 'float',
|
|
|
|
'cost' => 'float',
|
|
|
|
'capacity' => 'integer',
|
|
|
|
'active' => 'boolean',
|
2017-12-14 01:29:14 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
public static $rules = [
|
2018-03-22 01:35:06 +08:00
|
|
|
'code' => 'required',
|
2017-12-14 01:29:14 +08:00
|
|
|
'name' => 'required',
|
|
|
|
];
|
2017-06-11 07:27:19 +08:00
|
|
|
|
2017-06-23 09:55:45 +08:00
|
|
|
/**
|
|
|
|
* any foreign keys
|
|
|
|
*/
|
2018-03-19 09:37:35 +08:00
|
|
|
public function subfleets()
|
|
|
|
{
|
2018-01-08 23:22:12 +08:00
|
|
|
return $this->belongsToMany(Subfleet::class, 'subfleet_fare')
|
|
|
|
->withPivot('price', 'cost', 'capacity');
|
2017-06-11 07:27:19 +08:00
|
|
|
}
|
|
|
|
}
|