model = new \app\common\model\ExpressDelivery(); } public function add () { if ($this->request->isAjax()) { $data = $this->request->post(); return $this->model->saveExpress($data); } return $this->fetch(); } public function edit ($id) { $data = $this->model->where(['id' => $id])->findOrEmpty()->toArray(); $items = Db::name('express_shipping_method')->where(['template_id' => $data['id']])->select()->toArray(); $this->assign('data', $data); $this->assign('items', $items); if ($this->request->isAjax()) { $data = $this->request->post(); return $this->model->saveExpress($data); } return $this->fetch(); } }