'require|integer|gt:0|checkLive', 'match_id' => 'require|integer|gt:0|checkMatch', 'title' => 'require|length:1,255', 'source_url' => 'require|max:500', ]; protected $message = [ 'id.require' => '直播线路id不能为空', 'id.integer' => '直播线路id须为整数', 'id.gt' => '直播线路id须大于0', 'match_id.require' => '赛事id不能为空', 'match_id.integer' => '赛事id须为整数', 'match_id.gt' => '赛事id须大于0', 'title.require' => '直播标题不能为空', 'title.length' => '直播标题长度须在1-255位字符', 'source_url.require' => '源地址不能为空', 'source_url.max' => '源地址长度不能超过500位字符', ]; public function sceneDetail() { return $this->only(['id']); } public function sceneAdd() { return $this->remove('id', 'require|integer|gt:0|checkLive') ->only(['match_id', 'title', 'source_url']); } public function sceneEdit() { return $this->only(['id', 'match_id', 'title', 'source_url']); } public function sceneDelete() { return $this->only(['id']); } public function checkLive($value) { $live = MatchLive::findOrEmpty($value); if ($live->isEmpty()) { return '直播线路不存在'; } return true; } public function checkMatch($value) { $match = MatchEvent::findOrEmpty($value); if ($match->isEmpty()) { return '赛事不存在'; } return true; } }