Files
usedcar/app/apis/model/VehicleNewSkusModel.php
T
2025-06-20 17:22:01 +08:00

78 lines
1.5 KiB
PHP

<?php
namespace app\apis\model;
use support\Model;
/**
* VehicleNewSkusModel
*/
class VehicleNewSkusModel 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_vehicle_new_skus';
/**
* 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', 'vehicle_id', 'sku_code', 'stock', 'price', 'status', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
public function skuAttributes()
{
return $this->hasMany(VehicleNewSkuAttributesModel::class, 'sku_id', 'id');
}
/**
* 单条翻译
*/
public function translation()
{
return $this->hasOne(VehicleNewSkusTranslationModel::class, 'sku_id')->where('locale', locale());
}
/**
* 多条翻译
*/
public function translations()
{
return $this->hasMany(VehicleNewSkusTranslationModel::class, 'sku_id');
}
}