BrokerPushConfigRequest.php
2.07 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
<?php
namespace App\Http\Container\AdminSection\Requests\System;
use App\Models\BrokerPushConfig;
use Hikoon\LaravelApi\Support\ApiRequest;
class BrokerPushConfigRequest extends ApiRequest
{
/**
* @return void
*/
protected function prepareForValidation(): void
{
$this->mergeIfMissing(['level_title' => '', 'match_title' => '']);
if (empty($this->input('level_title'))) {
$this->merge(['level_intro' => '']);
}
if (empty($this->input('match_title'))) {
$this->merge(['match_intro' => '']);
}
}
/**
* @return string[]
*/
public function rules(): array
{
return [
'identifier' => 'required|alpha:ascii|uppercase|max:32|unique:' . BrokerPushConfig::class . ',identifier,' . $this->route('push_config.id') . ',id,deleted_at,NULL',
'level_title' => 'sometimes|string|max:64',
'level_intro' => 'required_with:level_title|max:1000',
'match_title' => 'sometimes|string|max:64',
'match_intro' => 'required_with:match_title|max:1000'
];
}
/**
* @return string[]
*/
public function messages(): array
{
return [
'identifier.required' => '请输入分类',
'identifier.alpha' => '分类仅支持A-Z字母组合',
'identifier.uppercase' => '分类仅支持A-Z字母组合',
'identifier.max' => '分类长度超过最大长度:max',
'identifier.unique' => '分类已存在,无法添加',
'level_title.max' => '等级通知标题超出最大长度:max',
'level_intro.required_with' => '请输入等级通知内容',
'level_intro .max' => '等级通知内容超出最大长度:max',
'match_title.max' => '合作通知内容超出最大长度:max',
'match_intro.required_with' => '请输入合作通知内容',
'match_intro.max' => '合作通知内容超出最大长度:max',
];
}
}