Files
usedcar/app/apis/model/ArticleModel.php
T
2025-06-27 17:04:25 +08:00

68 lines
1.3 KiB
PHP

<?php
namespace app\apis\model;
use app\console\model\AdminsModel;
use app\console\model\CommentModel;
use support\Model;
/**
* ArticleModel
*/
class ArticleModel 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_article';
/**
* 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', 'locale', 'title', 'subtitle', 'cover', 'content', 'user_id', 'is_top', 'sort', 'status', 'publish_time', 'created_at', 'updated_at', 'deleted_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
public function comment()
{
return $this->hasMany(CommentModel::class, 'article_id', 'id');
}
public function creater()
{
return $this->belongsTo(AdminsModel::class, 'user_id','id');
}
}