getList(); return View::fetch('index', compact('list')); } /** * 添加 */ public function add() { if ($this->request->isPost()) { $model = new QrcodeModel; if ($model->add($this->postData('data'))) { return $this->renderSuccess('添加成功', url('food.shop.qrcode/index')); } $error = $model->getError() ?: '添加失败'; return $this->renderError($error); } return redirect(url('food.shop.qrcode/index')); } /** * 编辑 */ public function edit($id) { // 详情 $model = QrcodeModel::detail($id); if (!$this->request->isAjax()) { $shopModel = new ShopModel; $shop = $shopModel->getList(false);//获取门店列表 $table = []; //获取门店餐桌列表 for($n=0;$ngetList($shop[$n]['shop_id']); } return View::fetch('edit', compact('model','shop','table')); } // 更新记录 if ($model->edit($this->postData('data'))) { return $this->renderSuccess('操作成功', url('food.shop.qrcode/index')); } $error = $model->getError() ?: '操作失败'; return $this->renderError($error); } /** * 删除 */ public function delete($id) { $model = QrcodeModel::get($id); if($model->remove()) { return $this->renderSuccess('删除成功'); } $error = $model->getError() ?: '删除失败'; return $this->renderError($error); } }