ActivityUpdateRequest.php
3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace App\Http\Container\UserSection\Requests;
use App\Http\Request\ActivityExpandRequest;
use App\Http\Service\ActivityService;
class ActivityUpdateRequest extends ActivityExpandRequest
{
protected function prepareForValidation(): void
{
$this->merge(['is_lyric' => (int)ActivityService::isLyric($this->input('lyric'))]);
}
public function rules(): array
{
return [
'cover' => 'required|url',
'song_name' => 'required|string|between:0,100',
'expand.tag_ids' => 'array|between:0,3',
'expand.tag_ids.*' => 'numeric',
'expand.lyricist.ids' => 'array|max:2',
'expand.lyricist.ids.*' => 'numeric',
'expand.composer.ids' => 'array|max:2',
'expand.composer.ids.*' => 'numeric',
'expand.guide_source.url' => 'required|url',
'expand.guide_source.name' => 'required|string',
'expand.guide_source.size' => 'required|integer',
'expand.karaoke_source.url' => 'sometimes|url',
'expand.karaoke_source.name' => 'sometimes|string',
'expand.karaoke_source.size' => 'sometimes|integer',
'lyric' => 'required',
'is_lyric' => 'required|in:0,1',
];
}
public function messages(): array
{
return [
'cover.required' => '请上传封面',
'cover.url' => '无效的封面地址',
'song_name.required' => '请输入歌曲名称',
'song_name.between' => '歌曲名称长度应在:min~:max字节内',
'project_id.required' => '请选择关联厂牌',
'project_id.int' => '关联厂牌类型错误',
'expand.lyricist.ids.array' => '词作者(用户)类型错误',
'expand.lyricist.ids.max' => '词作者(用户)最多:max人',
'expand.lyricist.ids.*.numeric' => '词作者(用户)类型错误',
'expand.lyricist.supplement.array' => '词作者(未注册)类型错误',
'expand.lyricist.supplement.max' => '词作者(未注册)最多:max人',
'expand.lyricist.supplement.*.numeric' => '词作者(未注册)类型错误',
'expand.composer.ids.array' => '曲作者(用户)类型错误',
'expand.composer.ids.max' => '曲作者(用户)最多:max人',
'expand.composer.ids.*.numeric' => '曲作者(用户)类型错误',
'expand.composer.supplement.array' => '曲作者(未注册)类型错误',
'expand.composer.supplement.max' => '曲作者(未注册)最多:max人',
'expand.composer.supplement.*.numeric' => '曲作者(未注册)类型错误',
'expand.guide_source.url.required' => '请上传导唱文件',
'expand.guide_source.url.url' => '无效的导唱文件链接',
'expand.karaoke_source.url' => '请上传伴奏文件',
'expand.karaoke_source.url.url' => '无效的伴奏文件链接',
'lyric.required' => '请上传歌词文件',
'lyric.regex' => '歌词文件类型错误',
];
}
}