MaterialRequest.php
1.29 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
<?php
namespace App\Http\Container\AdminSection\Requests\System;
use Hikoon\LaravelApi\Support\ApiRequest;
class MaterialRequest extends ApiRequest
{
public function rules(): array
{
return match ($this->method()) {
'POST' => [
'data.*.type' => 'required',
'data.*.url' => 'required',
'data.*.expand' => 'required',
'data.*.expand.width' => 'required|integer',
'data.*.expand.height' => 'required|integer'
],
'PUT' => [
'type' => 'required',
'url' => 'required|url',
'weight' => 'required|integer',
'expand' => 'required'
],
default => []
};
}
public function messages(): array
{
return match ($this->method()) {
'POST' => [
'*.required' => '请选择上传素材',
'data.*.url.url' => '素材链接不正确',
],
'PUT' => [
'*.required' => '请选择上传素材',
'url.url' => '素材链接不正确',
'weight.integer' => '权重值异常'
],
default => []
};
}
}