BroadcastRoomValidate.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\validate\merchant;
  3. use think\Validate;
  4. class BroadcastRoomValidate extends Validate
  5. {
  6. protected $failException = true;
  7. protected $rule = [
  8. 'name|直播间名字' => 'require|min:3|max:17',
  9. 'cover_img|背景图' => 'require',
  10. 'share_img|分享图' => 'require',
  11. 'anchor_name|主播昵称' => 'require|min:4|max:15',
  12. 'anchor_wechat|主播微信号' => 'require',
  13. 'phone|联系电话' => 'require|mobile',
  14. 'start_time|直播时间' => 'require|array|length:2|checkTime',
  15. 'type|直播间类型' => 'require|in:0',
  16. 'screen_type|显示样式' => 'require|in:0,1',
  17. 'close_like|是否开启点赞' => 'require|in:0,1',
  18. 'close_goods|是否开启货架' => 'require|in:0,1',
  19. 'close_comment|是否开启评论' => 'require|in:0,1',
  20. 'replay_status|是否开启回放' => 'require|in:0,1',
  21. 'close_share|是否开启分享' => 'require|in:0,1',
  22. 'close_kf|是否开启客服' => 'require|in:0,1',
  23. ];
  24. protected function checkTime($value)
  25. {
  26. $start = strtotime($value[0]);
  27. $end = strtotime($value[1]);
  28. if ($end < $start) return '请选择正确的直播时间';
  29. if ($start < strtotime('+ 15 minutes')) return '开播时间必须大于当前时间15分钟';
  30. if ($start >= strtotime('+ 6 month')) return '开播时间不能在6个月后';
  31. if (($end - $start) < (60 * 30)) return '直播时间不得小于30分钟';
  32. if (($end - $start) > (60 * 60 * 24)) return '直播时间不得超过24小时';
  33. return true;
  34. }
  35. }