💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
例如访问: http://thinkcmf/agent/menu/edit/id/10 ## 代码 ``` <?php namespace app\agent\controller; use think\Controller; use think\Db; use tree\Tree; class MenuController extends Controller { /** * 后台菜单编辑 */ public function edit() { $tree = new Tree(); $id = $this->request->param("id", 0, 'intval'); $rs = Db::name('AdminMenu')->where(["id" => $id])->find(); $result = Db::name('AdminMenu')->order(["list_order" => "ASC"])->select(); $array = []; foreach ($result as $r) { $r['selected'] = $r['id'] == $rs['parent_id'] ? 'selected' : ''; $array[] = $r; } $str = "<option value='\$id' \$selected>\$spacer \$name</option>"; $tree->init($array); $selectCategory = $tree->getTree(0, $str); $this->assign("data", $rs); $this->assign("select_category", $selectCategory); return $this->fetch(); } } ``` ## 要点解析 不多说,如图: ![mark](http://qiniu.newthink.cc/blog/20171019-122108114.png)