<?php
declare (strict_types = 1);

namespace app\index\model;

use app\common\model\AttachmentCategoryBaseModel;
use think\model\concern\SoftDelete;

/**
 * 附件分类模型
 * @mixin \think\Model
 */
class AttachmentCategoryModel extends AttachmentCategoryBaseModel
{
    // 启用软删除
    use SoftDelete;
    // 软删除时间字段名
    protected $deleteTime = 'deleted_at';

    // 所属语言范围查询
    public function scopeLanguage($query, $language)
    {
        return $query->where('language_id', '=', $language);
    }

    // 上级id范围查询
    public function scopeParent($query, $pid)
    {
        return $query->where('pid', '=', $pid);
    }

    // 是否显示状态范围查询
    public function scopeIsShow($query, bool $is_show)
    {
        return $query->where('is_show', '=', (int)$is_show);
    }
}
