request->isAjax()){ $get = $this->request->get(); $lists = ShopLevelLogic::lists($get); return JsonServer::success('', $lists); } return view(); } public function add() { if($this->request->isAjax()) { $post = $this->request->post(); // try{ // $post = $this->request->post(); // validate(LevelValidate::class)->scene('add')->check($post); // }catch(ValidateException $e) { // return JsonServer::error($e->getError()); // } $result = ShopLevelLogic::add($post); if($result === true) { return JsonServer::success('添加成功'); } return JsonServer::error(ShopLevelLogic::getError()); } return view(); } public function edit(){ if($this->request->isAjax()){ $post = $this->request->post(); // try{ // validate(LevelValidate::class)->scene('edit')->check($post); // }catch(ValidateException $e) { // return JsonServer::error($e->getError()); // } $result = ShopLevelLogic::edit($post); if($result === true) { return JsonServer::success('编辑成功'); } return JsonServer::error(ShopLevelLogic::getError()); } $id = $this->request->get('id', '', 'intval'); $detail = ShopLevelLogic::detail($id); return view('', [ 'detail' => $detail ]); } public function del() { $id = $this->request->post('id', '', 'intval'); $result = ShopLevelLogic::del($id); if($result === true) { return JsonServer::success('删除成功'); } return JsonServer::error(ShopLevelLogic::getError()); } /** * @Notes: 隐藏帮助分类 * @Author: 张无忌 */ public function hide() { if ($this->request->isAjax()) { $id = $this->request->post('id'); $res = ShopLevelLogic::hide($id); if ($res === false) { $error = ShopLevelLogic::getError() ?: '操作失败'; return JsonServer::error($error); } return JsonServer::success('操作成功'); } return JsonServer::success('异常'); } }