1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-26 04:21:27 +08:00
course-tencent-cloud/app/Validators/ChapterOffline.php

37 lines
880 B
PHP

<?php
namespace App\Validators;
use App\Exceptions\BadRequest as BadRequestException;
use App\Library\Validators\Common as CommonValidator;
class ChapterOffline extends Validator
{
public function checkStartTime($startTime)
{
if (!CommonValidator::date($startTime, 'Y-m-d H:i:s')) {
throw new BadRequestException('chapter_offline.invalid_start_time');
}
return strtotime($startTime);
}
public function checkEndTime($endTime)
{
if (!CommonValidator::date($endTime, 'Y-m-d H:i:s')) {
throw new BadRequestException('chapter_offline.invalid_end_time');
}
return strtotime($endTime);
}
public function checkTimeRange($startTime, $endTime)
{
if ($startTime >= $endTime) {
throw new BadRequestException('chapter_offline.start_gt_end');
}
}
}