This commit is contained in:
2025-07-08 09:59:28 +08:00
parent 4eff70e39e
commit 550e9500f3
18 changed files with 1018 additions and 3 deletions
+72
View File
@@ -0,0 +1,72 @@
<?php
namespace app\console\model;
use support\Model;
/**
* AdModel
*/
class AdModel 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_ad';
/**
* 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', 'image', 'status', 'sort', 'creater', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
/**
* 单条翻译
*/
public function translation()
{
return $this->hasOne(AdTranslationModel::class, 'ad_id')->where('locale', locale());
}
/**
* 多条翻译
*/
public function translations()
{
return $this->hasMany(AdTranslationModel::class, 'ad_id');
}
}