116 lines
2.3 KiB
PHP
116 lines
2.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace app\applet\model;
|
||
|
|
|
||
|
|
use support\Model;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* DraftsModel
|
||
|
|
*/
|
||
|
|
class DraftsDataModel extends Model
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* The connection name for the model.
|
||
|
|
*
|
||
|
|
* @var string|null
|
||
|
|
*/
|
||
|
|
protected $connection = 'mysql';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The table associated with the model.
|
||
|
|
*
|
||
|
|
* @var string
|
||
|
|
*/
|
||
|
|
protected $table = 'hs_drafts_data';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The primary key associated with the table.
|
||
|
|
*
|
||
|
|
* @var string
|
||
|
|
*/
|
||
|
|
protected $primaryKey = 'id';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Indicates if the model should be timestamped.
|
||
|
|
*
|
||
|
|
* @var bool
|
||
|
|
*/
|
||
|
|
public $timestamps = true;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 模型的数据字段的保存格式。
|
||
|
|
*
|
||
|
|
* @var string
|
||
|
|
*/
|
||
|
|
protected $dateFormat = 'U';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 允许自动填充模型字段
|
||
|
|
*/
|
||
|
|
protected $fillable = ['id', 'vin', 'user_id', 'cover', 'price', 'brand', 'type', 'energy', 'model', 'mileage', 'vehicle_age', 'vehicle_age', 'created_at', 'updated_at'];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 不允许自动填充模型字段
|
||
|
|
*/
|
||
|
|
protected $guarded = [];
|
||
|
|
|
||
|
|
const TRANS_FIELDS = [
|
||
|
|
'name', 'condition_desc'
|
||
|
|
];
|
||
|
|
|
||
|
|
public function user()
|
||
|
|
{
|
||
|
|
return $this->belongsTo(UsersModel::class, 'user_id', 'id');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function types()
|
||
|
|
{
|
||
|
|
return $this->belongsTo(TypesModel::class, 'type', 'id');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function energy()
|
||
|
|
{
|
||
|
|
return $this->belongsTo(EnergyModel::class, 'energy', 'id');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function album()
|
||
|
|
{
|
||
|
|
return $this->hasOne(VehicleAlbumModel::class, 'vehicle_data_id', 'id');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function apply()
|
||
|
|
{
|
||
|
|
return $this->hasOne(VehicleApplyModel::class, 'vehicle_data_id', 'id');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function brand()
|
||
|
|
{
|
||
|
|
return $this->belongsTo(BrandModel::class, 'brand');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function models()
|
||
|
|
{
|
||
|
|
return $this->belongsTo(ModelModel::class, 'model');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function location()
|
||
|
|
{
|
||
|
|
return $this->belongsTo(LocationModel::class, 'location');
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 单条翻译
|
||
|
|
*/
|
||
|
|
public function translation()
|
||
|
|
{
|
||
|
|
return $this->hasOne(VehicleDataTranslationModel::class, 'vehicle_id')->where('locale', locale());
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 多条翻译
|
||
|
|
*/
|
||
|
|
public function translations()
|
||
|
|
{
|
||
|
|
return $this->hasMany(VehicleDataTranslationModel::class, 'vehicle_id');
|
||
|
|
}
|
||
|
|
}
|