Feedback.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\api\user;
  12. use crmeb\basic\BaseController;
  13. use app\common\repositories\user\FeedbackRepository;
  14. use app\validate\api\FeedbackValidate;
  15. use think\App;
  16. class Feedback extends BaseController
  17. {
  18. protected $repository;
  19. public function __construct(App $app, FeedbackRepository $repository)
  20. {
  21. parent::__construct($app);
  22. $this->repository = $repository;
  23. }
  24. /**
  25. * @param FeedbackValidate $validate
  26. * @param FeedbackRepository $repository
  27. * @return mixed
  28. * @author xaboy
  29. * @day 2020/5/28
  30. */
  31. public function feedback(FeedbackValidate $validate)
  32. {
  33. $data = $this->request->params(['type', 'content', ['images', []], 'realname', 'contact',['status',0]]);
  34. $validate->check($data);
  35. $data['uid'] = $this->request->uid();
  36. $FeedBack = $this->repository->create($data);
  37. event('user.feedback',compact('FeedBack'));
  38. return app('json')->success('反馈成功');
  39. }
  40. /**
  41. * @return mixed
  42. * @author xaboy
  43. * @day 2020/5/28
  44. */
  45. public function feedbackList()
  46. {
  47. [$page, $limit] = $this->getPage();
  48. return app('json')->success($this->repository->getList(['uid' => $this->request->uid(),'is_del' => 0], $page, $limit));
  49. }
  50. public function detail($id)
  51. {
  52. if (!$this->repository->uidExists($id, $this->request->uid()))
  53. return app('json')->fail('数据不存在');
  54. $feedback = $this->repository->get($id);
  55. return app('json')->success($feedback);
  56. }
  57. }