💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
~~~ /** * 修改颜色 */ public function edit() { $id = input('post.id/d'); // 准备更新的数据 $data = $this->_postData(); // 避免新数据和其他数据名称重复 $isExists = self::where('name', $data['name']) ->where('id', '<>', $id) ->find(); if ($isExists !== null) { return res(203, '该颜色名称已存在'); } // 数据验证 try { validate('app\index\validate\DoorColor.edit')->check($data); } catch (\think\exception\ValidateException $e) { return res(201, $e->getError()); } // 执行更新 try { self::update($data, ['id' => $id]); } catch (\think\db\exception\PDOException $e) { return res(202, $e->getMessage()); } return res(200, '修改成功'); } ~~~