model = new \app\common\model\Feedback(); } /** * 意见反馈添加 * @return void */ public function add() { try { $content = $this->request->param('content',''); $images = $this->request->param('images',''); //验证参数 $validate = validate('Feedback'); if(!$validate->check($this->request->param(),[],'add')){ throw new Exception($validate->getError()); } $userId = $this->auth->id; $content = $content; $images = $images; $limitNum = 100;//限制每月反馈数量 $feedbackNum = $this->model->getMonthNum($userId); if ($feedbackNum >= $limitNum) { throw new Exception('您反馈的意见过多,请在次月再反馈'); } $data = [ 'user_id' => $userId, 'content' => $content, 'images' => $images, 'createtime' => time(), ]; $addRes = $this->model->insertGetId($data); if (!$addRes) { throw new Exception('操作失败'); } $this->success('操作成功'); } catch (Exception $e) { $this->error($e->getMessage()); } } }