| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace app\api\controller\service;
- use app\common\controller\Api;
- use think\Validate;
- /**
- * 首页接口
- */
- class Feedback extends Api
- {
- protected $noNeedLogin = [''];
- protected $noNeedRight = ['*'];
- public function submitFeedback()
- {
- if (!$this->request->isPost()) {
- $this->error('请求方式异常');
- }
- $uid = $this->auth->id;
- $post = input('post.','','trim,strip_tags,htmlspecialchars,xss_clean');
- $rule = [
- 'mobile' => 'number',
- 'content'=> 'require',
- 'type' => 'require',
- ];
- $msg = [
- 'mobile.number' => '手机号必须是数字',
- 'content.require'=> '请填写反馈内容',
- 'type.require' => '请提交用户身份'
- ];
- $validate = new Validate($rule, $msg);
- $result = $validate->check($post);
- if (!$result) {
- $this->error($validate->getError());
- }
- $post['user_id'] = $uid;
- $applySkill = new \app\api\model\service\Feedback();
- $applySkill->data($post)->save();
- $this->success('反馈意见已提交');
- }
- }
|