lcly-data-admin/app/Http/Requestes/CropYieldRequest.php

42 lines
1.2 KiB
PHP

<?php
namespace App\Http\Requestes;
use App\Rules\Quarter;
use App\Rules\Year;
use Illuminate\Foundation\Http\FormRequest;
class CropYieldRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'time_year' => ['bail', 'required', new Year()],
'quarter' => ['bail', 'required', new Quarter()],
'crop_id' => 'required|integer|min:0',
'base_id' => 'required|integer|min:0',
'yield' => ['bail', 'required', 'numeric', 'min:0', 'max:9999999999.99', 'regex:/^([1-9]\d*|0)(\.\d{1,2})?$/'],
'cultivated' => ['bail', 'required', 'numeric', 'min:0', 'max:9999999999.99', 'regex:/^([1-9]\d*|0)(\.\d{1,2})?$/'],
'output' => ['bail', 'required', 'numeric', 'min:0', 'max:9999999999.99', 'regex:/^([1-9]\d*|0)(\.\d{1,2})?$/'],
];
}
public function attributes()
{
return [
'time_year' => '年份',
'quarter' => '季度',
'crop_id' => '农作物',
'base_id' => '地区',
'yield' => '产量',
'cultivated' => '耕种面积',
'output' => '产值',
];
}
}