Files
usedcar/app/apis/model/AdpModel.php
T
2025-07-10 18:08:08 +08:00

96 lines
1.7 KiB
PHP

<?php
namespace app\apis\model;
use support\Model;
/**
* AdpModel
*/
class AdpModel 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_adp';
/**
* 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', 'status', 'new_url', 'used_url', 'sort', 'creater', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
/**
* 单条翻译
*/
public function translation()
{
return $this->hasOne(AdpTranslationModel::class, 'adp_id')->where('locale', locale());
}
/**
* 多条翻译
*/
public function translations()
{
return $this->hasMany(AdpTranslationModel::class, 'adp_id');
}
/**
* 广告
*/
public function ad()
{
return $this->hasMany(AdModel::class, 'adp_id','id');
}
/**
* 广告
*/
public function new_ad()
{
return $this->hasMany(AdModel::class, 'adp_id','id')->where(['type' => 1]);
}
/**
* 广告
*/
public function used_ad()
{
return $this->hasMany(AdModel::class, 'adp_id','id')->where(['type' => 2]);
}
}