feat: 新增文章评论分页列表接口

This commit is contained in:
2025-01-15 17:56:39 +08:00
parent 110e997423
commit 83c4ae38fc
4 changed files with 125 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
<?php
declare (strict_types = 1);
namespace app\admin\model\v1;
use app\common\model\ArticleLeaveMessageBaseModel;
/**
* @mixin \think\Model
*/
class ArticleLeaveMessageModel extends ArticleLeaveMessageBaseModel
{
// 关联文章
public function article()
{
return $this->belongsTo(ArticleModel::class, 'article_id', 'id');
}
// 审核状态查询
public function scopeIsAudited($query, $is_audited)
{
if (is_null($is_audited)) {
return;
}
$query->where('is_audited', '=', $is_audited);
}
// 搜索留言内容
public function searchCreatedAtAttr($query, $value, $data)
{
if (empty($value)) {
return;
}
$val = explode(',', $value);
if (count($val) > 1) {
$query->whereBetweenTime('created_at', $val[0], $val[1]);
} else {
$query->whereTime('created_at', '>=', $val[0]);
}
}
}