phpvms/app/Models/Fare.php

56 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace App\Models;
2018-08-27 00:40:04 +08:00
use App\Contracts\Model;
/**
2020-03-03 06:38:48 +08:00
* @property string name
* @property float cost
* @property float price
2020-03-03 06:38:48 +08:00
* @property int code
* @property int capacity
* @property int count Only when merged with pivot
* @property int type
2020-03-03 06:38:48 +08:00
* @property string notes
* @property bool active
*/
class Fare extends Model
{
public $table = 'fares';
2018-03-21 08:40:19 +08:00
protected $fillable = [
'code',
'name',
2020-03-07 05:54:53 +08:00
'type',
'price',
'cost',
'capacity',
'notes',
'active',
];
protected $casts = [
'price' => 'float',
'cost' => 'float',
'capacity' => 'integer',
'type' => 'integer',
'active' => 'boolean',
];
public static $rules = [
2018-03-22 01:35:06 +08:00
'code' => 'required',
'name' => 'required',
'type' => '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');
}
}