You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.2 KiB
42 lines
1.2 KiB
<?php
|
|
|
|
namespace app\admin\validate;
|
|
|
|
use app\admin\model\LiveRoom;
|
|
use think\Validate;
|
|
|
|
class LiveRoomValidate extends Validate
|
|
{
|
|
|
|
|
|
protected $rule = [
|
|
'id|编号' => 'require|number',
|
|
'room_id|房间号' => 'require|alphaNum|max:50',
|
|
'anchor_information|主播信息' => 'require',
|
|
'link|直播间链接' => 'require|checkLink',
|
|
'status|状态' => 'require|in:0,1',
|
|
];
|
|
|
|
protected $message = [];
|
|
|
|
protected $scene= [
|
|
'add' => ['room_id', 'anchor_information', 'link', 'status'],
|
|
'edit' => ['id', 'room_id', 'anchor_information', 'link', 'status']
|
|
];
|
|
|
|
protected function checkLink($value, $rule, $data=[])
|
|
{
|
|
if (strpos($value, 'http://') !== 0 && strpos($value, 'https://') !== 0) {
|
|
return '直播间链接填写错误';
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static function existsRoomId($room_id, $id = 0)
|
|
{
|
|
$where = [['room_id', "=", $room_id]];
|
|
if ($id > 0) $where[] = ['id', '<>', $id];
|
|
$res = LiveRoom::where($where)->find();
|
|
return !$res ? true : '房间号已存在';
|
|
}
|
|
}
|
|
|