ldc-crm/app/Http/Requests/CustomerExport.php

42 lines
1 KiB
PHP
Raw Permalink Normal View History

<?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'));
}
}
]
];
}
}