截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CommunityCommentValidate.php 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace app\admin\validate\community;
  3. use app\common\basics\Validate;
  4. use app\common\model\community\CommunityComment;
  5. /**
  6. * 社区种草评论验证
  7. * Class CommunityCommentValidate
  8. * @package app\admin\validate\community
  9. */
  10. class CommunityCommentValidate extends Validate
  11. {
  12. protected $rule = [
  13. 'id' => 'require|number|checkComment',
  14. 'status' => 'require|in:1,2',
  15. ];
  16. protected $message = [
  17. 'id.require' => 'id不可为空',
  18. 'id.number' => 'id必须为数字',
  19. 'status.require' => '请选择审核状态',
  20. 'status.in' => '审核状态值异常',
  21. ];
  22. protected $scene = [
  23. 'audit' => ['id', 'status'],
  24. 'id' => ['id'],
  25. ];
  26. /**
  27. * @notes 校验评论
  28. * @param $value
  29. * @param $rule
  30. * @param $data
  31. * @return bool|string
  32. * @author 段誉
  33. * @date 2022/5/10 15:08
  34. */
  35. protected function checkComment($value, $rule, $data)
  36. {
  37. $comment = CommunityComment::where(['del' => 0])->findOrEmpty($value);
  38. if ($comment->isEmpty()) {
  39. return '评论信息不存在';
  40. }
  41. return true;
  42. }
  43. }