belongsTo(AiKnowledgeBaseType::class, 'typeId', 'id'); } /** * 获取有效的知识库列表(未删除) */ public static function getValidList($companyId, $typeId = null) { $where = [ ['isDel', '=', 0], ['companyId', '=', $companyId] ]; if ($typeId !== null) { $where[] = ['typeId', '=', $typeId]; } return self::where($where) ->with(['type']) ->order('createTime', 'desc') ->select(); } }