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