request->input('kitchen_id'); $limit = (int)$this->request->input('limit'); $list = $this->printerModel->where('kitchen_id', $kitchenId)->paginate($limit)->toArray(); return $this->return->success('success', $list); } /** * @return array */ public function add(): array { $insertModel = new Printer(); $insertModel->kitchen_id = $this->request->input('kitchen_id'); $insertModel->name = $this->request->input('name'); $insertModel->type = $this->request->input('type'); $insertModel->code_value = $this->request->input('code_value'); if (!$insertModel->save()) throw new ErrException('添加失败'); return $this->return->success(); } /** * @return array */ public function edit(): array { $id = (int)$this->request->input('id'); $info = $this->printerModel->find($id); if (empty($info)) throw new ErrException('未找到数据'); $info->kitchen_id = $this->request->input('kitchen_id'); $info->name = $this->request->input('name'); $info->type = $this->request->input('type'); $info->code_value = $this->request->input('code_value'); if (!$info->save()) throw new ErrException('修改失败'); return $this->return->success(); } /** * @return array * @throws Exception */ public function del(): array { $id = (int)$this->request->input('id'); $info = $this->printerModel->find($id); if (empty($info)) throw new ErrException('未找到数据'); if (!$info->delete()) throw new ErrException('删除失败'); return $this->return->success(); } }