截流自动化的商城平台
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.

CommunityArticleValidate.php 1.3KB

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