lcly-data-admin/app/Http/Requestes/MaterielUpdateRequest.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 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', 'regex:/^([1-9]\d*|0)(\.\d{1,2})?$/'],
'highest_price' => ['filled', 'regex:/^([1-9]\d*|0)(\.\d{1,2})?$/', 'gte:lowest_price'],
'unit' => ['filled', 'string'],
];
}
public function attributes()
{
return [
'year' => '年份',
'quarter' => '季度',
'name' => '名称',
'type' => '类型',
'lowest_price' => '最低价',
'highest_price' => '最高价',
'unit' => '单位',
];
}
}