feat: 新增文章评论分页列表接口
This commit is contained in:
42
app/admin/model/v1/ArticleLeaveMessageModel.php
Normal file
42
app/admin/model/v1/ArticleLeaveMessageModel.php
Normal 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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user