1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-24 04:01:31 +08:00
koogua 0336a54911 1.源文件增加版权信息
2.群组状态和课程协同
2021-06-13 15:49:47 +08:00

46 lines
1.1 KiB
PHP

<?php
/**
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
namespace App\Validators;
use App\Exceptions\BadRequest as BadRequestException;
use App\Library\Validators\Common as CommonValidator;
class ChapterLive extends Validator
{
public function checkStartTime($startTime)
{
if (!CommonValidator::date($startTime, 'Y-m-d H:i:s')) {
throw new BadRequestException('chapter_live.invalid_start_time');
}
return strtotime($startTime);
}
public function checkEndTime($endTime)
{
if (!CommonValidator::date($endTime, 'Y-m-d H:i:s')) {
throw new BadRequestException('chapter_live.invalid_end_time');
}
return strtotime($endTime);
}
public function checkTimeRange($startTime, $endTime)
{
if ($startTime >= $endTime) {
throw new BadRequestException('chapter_live.start_gt_end');
}
if ($endTime - $startTime > 3 * 3600) {
throw new BadRequestException('chapter_live.time_too_long');
}
}
}