BroadcastRoomValidate.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\validate\merchant;
  12. use think\Validate;
  13. class BroadcastRoomValidate extends Validate
  14. {
  15. protected $failException = true;
  16. protected $rule = [
  17. 'name|直播间名字' => 'require|min:3|max:17',
  18. 'cover_img|背景图' => 'require',
  19. 'share_img|分享图' => 'require',
  20. 'anchor_name|主播昵称' => 'require|min:4|max:15',
  21. 'anchor_wechat|主播微信号' => 'require',
  22. 'phone|联系电话' => 'require|mobile',
  23. 'start_time|直播时间' => 'require|array|length:2|checkTime',
  24. 'type|直播间类型' => 'require|in:0',
  25. 'screen_type|显示样式' => 'require|in:0,1',
  26. 'close_like|是否开启点赞' => 'require|in:0,1',
  27. 'close_goods|是否开启货架' => 'require|in:0,1',
  28. 'close_comment|是否开启评论' => 'require|in:0,1',
  29. 'replay_status|是否开启回放' => 'require|in:0,1',
  30. 'close_share|是否开启分享' => 'require|in:0,1',
  31. 'close_kf|是否开启客服' => 'require|in:0,1',
  32. ];
  33. protected function checkTime($value)
  34. {
  35. $start = strtotime($value[0]);
  36. $end = strtotime($value[1]);
  37. if ($end < $start) return '请选择正确的直播时间';
  38. if ($start < strtotime('+ 15 minutes')) return '开播时间必须大于当前时间15分钟';
  39. if ($start >= strtotime('+ 6 month')) return '开播时间不能在6个月后';
  40. if (($end - $start) < (60 * 30)) return '直播时间不得小于30分钟';
  41. if (($end - $start) > (60 * 60 * 24)) return '直播时间不得超过24小时';
  42. return true;
  43. }
  44. }