Burst.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\common\validate;
  3. use think\Db;
  4. use think\Validate;
  5. class Burst extends Validate{
  6. protected $rule = [
  7. 'title|事件名称' => 'require|length:1,200',
  8. 'content|事件流程' => 'require|checkContent',
  9. ];
  10. protected $message = [
  11. 'title.length' => '名称必须200字以内',
  12. ];
  13. protected $scene = [
  14. ];
  15. protected function checkContent($value, $rule, $data=[]){
  16. $content = json_decode($data['content'],true);
  17. foreach ($content as $k=>$v){
  18. if(!$v['title']){
  19. return '事件流程部分内容未填写';
  20. }
  21. if(!$v['time']){
  22. return '事件流程部分内容未填写';
  23. }
  24. if(count($v['options']) == 0){
  25. return '事件流程部分内容未填写';
  26. }
  27. foreach ($v['options'] as $key=>$val){
  28. if(!$val['text']){
  29. return '事件流程部分内容未填写';
  30. }
  31. }
  32. }
  33. return true;
  34. }
  35. }