getList($this->applet_id); $wechat = WechatModel::detail($this->applet_id); return View::fetch('../../admin/view/wechat/keyword/index', compact('list','wechat')); } /** * 添加 */ public function add() { if ($this->request->isPost()) { $model = new KeywordModel; // 新增记录 if ($model->add($this->postData('data'),$this->applet_id)) { return $this->renderSuccess('添加成功', url('wechat.keyword/index')); } $error = $model->getError() ?: '添加失败'; return $this->renderError($error); } return redirect(url('wechat.keyword/index')); } /** * 删除 */ public function delete($id) { $model = KeywordModel::get($id); if (!$model->remove()) { return $this->renderError('删除失败'); } return $this->renderSuccess('删除成功'); } /** * 编辑 */ public function edit($id) { $model = KeywordModel::get($id); if ($this->request->isGet()) { if($model){ return $this->renderSuccess('', '', compact('model')); } return $this->renderError('获取失败'); } // 更新记录 if ($model->edit($this->postData('data'))) { return $this->renderSuccess('更新成功', url('wechat.keyword/index')); } $error = $model->getError() ?: '更新失败'; return $this->renderError($error); } /** * 状态编辑 */ public function status($id) { $model = KeywordModel::get($id); // 更新记录 if ($model->status()) { return $this->renderSuccess('更新成功', url('wechat.keyword/index')); } $error = $model->getError() ?: '更新失败'; return $this->renderError($error); } }