feat: 文章相关

This commit is contained in:
2025-04-12 14:34:07 +08:00
parent 111b648b36
commit 14ff19ea93
7 changed files with 123 additions and 82 deletions

View File

@@ -16,4 +16,29 @@ class ArticleCategoryModel extends ArticleCategoryBaseModel
use SoftDelete;
// 软删除字段
protected $deleteTime = 'deleted_at';
// 关联文章
public function article()
{
return $this->hasMany(ArticleModel::class, 'category_id', 'id');
}
// 所属语言范围查询
public function scopeLanguage($query, $language)
{
$query->where('language_id', '=', $language);
}
// 所属上级分类范围查询
public function scopeParent($query, $parent)
{
if (is_null($parent)) return;
$query->where('pid', '=', $parent);
}
// 是否显示状态范围查询
public function scopeIsShow($query, bool $is_show)
{
$query->where('is_show', '=', (int)$is_show);
}
}