/** * 返回树形选择 * @param string 分类模型 * @param integer $unShowId 排除显示的节点 * @return array */ public function treeSelect($model = '', $unShowId = 0) { $map['status'] = 1; if ($unShowId) { $map['id'] = ['neq', $unShowId]; } if ($model) { $map['model'] = $model; } $categorys = Db::name('category')->where($map)->order('sort asc')->select(); return Tree::toFormatTree($categorys); }
private function _treeShow($id = 0) { $map = []; if ($id) { $map['id'] = ['neq', $id]; } $menus = Db::name('Menu')->where($map)->order('sort asc')->select(); $menus = \tools\Tree::toFormatTree($menus); $menus = array_merge([0 => ['id' => 0, 'title_show' => '顶级菜单']], $menus); return $menus; }