43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requestes;
|
|
|
|
use App\Enums\MaterielType;
|
|
use App\Rules\Quarter;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rules\Enum;
|
|
|
|
class MaterielStoreRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
'year' => ['required', 'int'],
|
|
'quarter' => ['required', new Quarter()],
|
|
'name' => ['required', 'string', 'max:255'],
|
|
'type' => ['required', new Enum(MaterielType::class)],
|
|
'lowest_price' => ['required', 'int'],
|
|
'highest_price' => ['required', 'int', 'gte:lowest_price'],
|
|
'unit' => ['required', 'string'],
|
|
];
|
|
}
|
|
|
|
public function attributes()
|
|
{
|
|
return [
|
|
'year' => '年份',
|
|
'quarter' => '季度',
|
|
'name' => '名称',
|
|
'type' => '类型',
|
|
'lowest_price' => '最低价',
|
|
'highest_price' => '最高价',
|
|
'unit' => '单位',
|
|
];
|
|
}
|
|
}
|