61 lines
1.2 KiB
PHP
61 lines
1.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace app\model;
|
||
|
|
|
||
|
|
use support\Model;
|
||
|
|
|
||
|
|
class LocationEn extends Model
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* The table associated with the model.
|
||
|
|
*
|
||
|
|
* @var string
|
||
|
|
*/
|
||
|
|
protected $table = 'locations_en';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The primary key associated with the table.
|
||
|
|
*
|
||
|
|
* @var string
|
||
|
|
*/
|
||
|
|
protected $primaryKey = 'id';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Indicates if the model should be timestamped.
|
||
|
|
*
|
||
|
|
* @var bool
|
||
|
|
*/
|
||
|
|
public $timestamps = false;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the vehicles for the location.
|
||
|
|
*/
|
||
|
|
public function vehicles()
|
||
|
|
{
|
||
|
|
return $this->hasMany(VehicleEn::class, 'locations_id', 'id');
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* 目的地关联
|
||
|
|
* Get the vehicles for the location.
|
||
|
|
*/
|
||
|
|
public function finalVehicles()
|
||
|
|
{
|
||
|
|
return $this->hasMany(VehicleEn::class, 'final_locations_id', 'id');
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the FBO vehicles for the location.
|
||
|
|
*/
|
||
|
|
public function fboVehicles()
|
||
|
|
{
|
||
|
|
return $this->hasMany(VehicleEn::class, 'fbo_locations_id', 'id');
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Scope a query to only include locations that have vehicles.
|
||
|
|
*/
|
||
|
|
public function scopeHasVehicles($query)
|
||
|
|
{
|
||
|
|
return $query->whereHas('vehicles_en');
|
||
|
|
}
|
||
|
|
}
|