Files

80 lines
1.6 KiB
PHP
Raw Permalink Normal View History

2025-05-14 13:19:23 +08:00
<?php
namespace app\console\model;
use support\Model;
/**
* BrandModel
*/
class BrandModel 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';
/**
* 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';
/**
* 允许自动填充模型字段
*/
2025-06-06 14:08:10 +08:00
protected $fillable = ['id', 'status', 'sort', 'toppic', 'descpic', 'logo', 'letter', 'is_hot', 'creater', 'created_at', 'updated_at'];
2025-05-14 13:19:23 +08:00
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
public function translation()
{
return $this->hasOne(BrandTranslationModel::class, 'brand_id')->where('locale', locale());
}
public function translations()
{
return $this->hasMany(BrandTranslationModel::class, 'brand_id');
}
2025-05-21 11:28:30 +08:00
public function banner()
{
return $this->hasMany(BrandBannerModel::class, 'brand_id','id');
}
public function trait()
{
return $this->hasMany(BrandTraitModel::class, 'brand_id','id');
}
2025-06-06 14:08:10 +08:00
public function creater()
{
return $this->belongsTo(AdminsModel::class, 'creater','id');
}
2025-05-14 13:19:23 +08:00
}