value('id'); return self::where('pid', $aboutId)->column('id'); } /** * 获取病种相关模型的栏目 模型名称为:'question', 'diary', 'effect', 'science' * * @return string[] */ public static function diseaseCategoryIds(): array { $modelIds = ArchivesModel::whereIn('name', ArchivesModel::models())->column('id'); return self::whereIn('model_id', $modelIds)->column('id'); } /** * 检测数据下 是否有子栏目 * * @param array $ids * @return bool */ public static function hasChildrenByIds(array $ids): bool { return self::whereIn('pid', $ids)->count() > 0; } /** * 检测数据下 是否有子内容 * * @param array $ids * @return bool */ public static function hasContentByIds(array $ids): bool { return Archives::whereIn('category_id', $ids)->count() > 0; } /** * 获取列表 * * @return ArchivesCategory[]|array|Collection * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException */ public static function getList() { return self::field('id,pid,title,name,sort,path,true as open') ->order('sort', 'desc') ->order('id', 'asc') ->select(); } /** * 模型 * * @return HasOne */ public function model(): HasOne { return $this->hasOne(ArchivesModel::class, 'id', 'model_id')->bind(['model' => 'name']); } }