'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 : '房间号已存在'; } }