41 lines
1 KiB
PHP
41 lines
1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use App\Enums\CustomerExportType;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class CustomerExport extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function authorize()
|
|
{
|
|
return auth()->check();
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
'brand' => 'required|numeric|exists:brands,id',
|
|
'export_type' => [
|
|
'required',
|
|
'numeric',
|
|
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
|
function ($attribute, $value, $fail) {
|
|
if (!\in_array($value, CustomerExportType::values())) {
|
|
$fail(trans('Le type d\'export invalide'));
|
|
}
|
|
}
|
|
]
|
|
];
|
|
}
|
|
}
|