Файл: app/Http/Requests/API/SelectStatsRequest.php
Строк: 38
<?php
namespace AppHttpRequestsAPI;
use IlluminateContractsValidationValidator;
use IlluminateFoundationHttpFormRequest;
use IlluminateHttpExceptionsHttpResponseException;
use IlluminateValidationRule;
class SelectStatsRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => ['required', Rule::in(config('stats.types'))],
'from' => ['required', 'date_format:Y-m-d'],
'to' => ['required', 'date_format:Y-m-d']
];
}
/**
* Handle a failed validation attempt.
*
* @param Validator $validator
*/
protected function failedValidation(Validator $validator)
{
throw new HttpResponseException(
response()->json([
'message' => $validator->errors(),
'status' => 422
], 422));
}
}