ldc-crm/app/Http/Requests/Bo/CustomerExport.php
2024-09-09 15:26:35 +02:00

41 lines
1 KiB
PHP

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