Files
orico-official-website/app/index/model/ArticleCategoryModel.php
2025-04-12 14:34:07 +08:00

45 lines
1002 B
PHP

<?php
declare (strict_types = 1);
namespace app\index\model;
use app\common\model\ArticleCategoryBaseModel;
use think\model\concern\SoftDelete;
/**
* 文章分类模型
* @mixin \think\Model
*/
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);
}
}