fix: 文章详情推荐文章
This commit is contained in:
@@ -46,6 +46,17 @@ class ArticleCategoryModel extends ArticleCategoryBaseModel
|
||||
$query->where('pid', '=', $parent);
|
||||
}
|
||||
|
||||
// 所属子分类范围查询
|
||||
public function scopeChild($query, $id, $merge_self = false)
|
||||
{
|
||||
$query->where(function($q) use($id, $merge_self) {
|
||||
$q->where('pid', '=', $id);
|
||||
if ($merge_self) {
|
||||
$q->whereOr('id', '=', $id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 是否显示状态范围查询
|
||||
public function scopeIsShow($query, bool $is_show)
|
||||
{
|
||||
|
||||
@@ -32,6 +32,11 @@ class ArticleModel extends ArticleBaseModel
|
||||
// 文章分类范围查询
|
||||
public function scopeCategory($query, $category)
|
||||
{
|
||||
if (is_null($category)) return;
|
||||
if (is_array($category)) {
|
||||
$query->where('category_id', 'in', $category);
|
||||
return;
|
||||
}
|
||||
$query->where('category_id', '=', $category);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user