2021-09-09 14:08:59 +02:00
|
|
|
<?php
|
|
|
|
|
|
2023-10-06 15:00:42 +02:00
|
|
|
namespace App\Http\Requests\Bo;
|
2021-09-09 14:08:59 +02:00
|
|
|
|
|
|
|
|
use App\Enums\CustomerExportType;
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
|
|
|
|
|
class CustomerExport extends FormRequest
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
|
*
|
2021-12-19 15:57:24 +01:00
|
|
|
* @return boolean
|
2021-09-09 14:08:59 +02:00
|
|
|
*/
|
2023-09-06 17:24:53 +02:00
|
|
|
public function authorize(): bool
|
2021-09-09 14:08:59 +02:00
|
|
|
{
|
2023-10-06 15:00:42 +02:00
|
|
|
return auth('backend')->check();
|
2021-09-09 14:08:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
2023-09-06 17:24:53 +02:00
|
|
|
public function rules(): array
|
2021-09-09 14:08:59 +02:00
|
|
|
{
|
|
|
|
|
return [
|
2023-09-04 13:08:34 +02:00
|
|
|
'brand' => 'required|numeric|exists:brands,id',
|
2021-09-09 14:08:59 +02:00
|
|
|
'export_type' => [
|
|
|
|
|
'required',
|
|
|
|
|
'numeric',
|
|
|
|
|
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
|
|
|
|
function ($attribute, $value, $fail) {
|
2023-09-04 13:08:34 +02:00
|
|
|
if (!\in_array($value, CustomerExportType::toValues())) {
|
2021-09-09 14:08:59 +02:00
|
|
|
$fail(trans('Le type d\'export invalide'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|