Files
usedcar/app/console/model/BrandBannerModel.php
T

83 lines
1.5 KiB
PHP
Raw Normal View History

2025-05-21 11:28:30 +08:00
<?php
namespace app\console\model;
use support\Model;
/**
* VehicleDataModel
*/
class BrandBannerModel 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_brand_banner';
/**
* 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', 'brand_id', 'pic', 'status', 'sort', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
public function brand()
{
return $this->belongsTo(BrandModel::class, 'brand_id');
}
/**
* 单条翻译
*/
public function translation()
{
2025-05-23 10:28:59 +08:00
return $this->hasOne(BrandBannerTranslationModel::class, 'banner_id')->where('locale', locale());
2025-05-21 11:28:30 +08:00
}
/**
* 多条翻译
*/
public function translations()
{
2025-05-23 10:28:59 +08:00
return $this->hasMany(VehicleDataTranslationModel::class, 'banner_id');
2025-05-21 11:28:30 +08:00
}
const TRANS_FIELDS = [
2025-05-23 10:28:59 +08:00
'alt'
2025-05-21 11:28:30 +08:00
];
}