order('id', 'desc')->field($fields)->select(); } /** * 获取上下级 * */ public static function getByGroup() { $top = self::column(['pid', 'name', 'id'], "id"); foreach ($top as $key => $value) { if (isset($top[$value["pid"]])) { $top[$value["pid"]]['children'][] = $value; unset($top[$key]); } } return $top; } /** * 获取全部列表 * * @return Collection * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException */ public static function getList() { return self::field('id,pid,name,commision')->order('id', 'desc')->select(); } /** * 病种 xmSelect json数据 * * @param int $pid * @param array $selected * @param array $disabled * @return array|Collection * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException */ public static function diseaseXmJson(int $pid = 0, array $selected = [], array $disabled = []) { $list = self::getListByPid($pid); foreach ($list as $k => $m) { $list[$k]['selected'] = in_array($m['id'], $selected); $list[$k]['disabled'] = in_array($m['id'], $disabled); } return $list; } }