ldc-legaulois/app/Http/Requests/Club/MesBr/PrintCouponsRequest.php
2026-09-25 16:25:31 +02:00

55 lines
1.3 KiB
PHP

<?php
namespace App\Http\Requests\Club\MesBr;
use Illuminate\Foundation\Http\FormRequest;
class PrintCouponsRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return auth('club')->check();
}
/**
* Prepare the data for validation.
*/
public function prepareForValidation(): void
{
/** @var array $coupons */
$coupons = $this->post('coupon');
$this->merge([
'coupon' => collect($coupons)
->filter()
->map(fn (string $value) => \is_numeric($value) ? intval($value) : $value)
->all(),
]);
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string,\Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'coupon' => 'required|array|min:1',
'coupon.*' => 'required|integer',
];
}
/**
* Get custom attributes for validator errors.
*/
public function attributes(): array
{
return [
'coupon' => trans('coupon'),
'coupon.*' => trans('coupon'),
];
}
}