ldc-legaulois/app/Http/Requests/GetMapBreeders.php
2022-02-10 16:14:58 +01:00

42 lines
1 KiB
PHP

<?php
namespace App\Http\Requests;
use App\Enums\OCBType;
use Illuminate\Foundation\Http\FormRequest;
class GetMapBreeders extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize()
{
return $this->ajax();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'isocb' => 'required|boolean',
'ocbtype' => [
'required',
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
function ($attribute, $value, $fail) {
if (!in_array($value, OCBType::toValues())) {
$fail(__('Veuillez choisir entre :values', [
'value' => implode(',', OCBType::toLabels())
]));
}
}
],
];
}
}