41 lines
966 B
PHP
41 lines
966 B
PHP
<?php
|
|
|
|
namespace App\Http\Requestes;
|
|
|
|
use App\Rules\Year;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
use Peidikeji\Keywords\Models\Keywords;
|
|
|
|
class RiceShrimpWeeklyPriceStoreRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
'year' => ['required', 'int', new Year()],
|
|
'week' => [
|
|
'required',
|
|
'int',
|
|
Rule::exists(Keywords::class, 'key')->where(function ($query) {
|
|
return $query->where('type_key', 'weeks-per-year');
|
|
}),
|
|
],
|
|
'price' => ['required', 'int', 'min:0', 'max:2147483647'],
|
|
];
|
|
}
|
|
|
|
public function attributes()
|
|
{
|
|
return [
|
|
'year' => '年份',
|
|
'week' => '周',
|
|
'price' => '价格',
|
|
];
|
|
}
|
|
}
|