catetree(); $this->assign('cateres',$cateres); return $this->fetch(); } public function add() { $cate = new Sys_menumodel(); if (request()->isPost()) { if($_POST['pid']){ $ppid=Db::table('sys_menu')->where('id',$_POST['pid'])->find(); $ppid=$ppid['pid']; }else{ $ppid = '-1'; } $data=input('post.'); $data['ppid']=$ppid; $add=$cate->save($data); if($add){ $this->success('添加菜单成功!'); }else{ $this->error('添加菜单失败!'); } } $cateres=$cate->catetree(); $this->assign('cateres',$cateres); return $this->fetch(); } public function del(){ $del=db('sys_menu')->delete(input('id')); if($del){ $this->success('节点删除成功! '); }else{ $this->error('节点删除失败!'); } } public function edit($id) { $cate=Db::table('sys_menu')->where('id',$id)->find(); $this->assign('cate',$cate); if (request()->isPost()) { $edi=Db::table('sys_menu')->where('id',$id)->update(['pidname'=>$_POST['pidname'],'linkurl'=>$_POST['linkurl']]); if($edi){ $this->success('节点编辑成功! '); }else{ $this->error('节点编辑失败!'); } } $cat = new Sys_menumodel(); $cateres=$cat->catetree(); $this->assign('cateres',$cateres); return $this->fetch(); } } ?>