2024-09-06 14:54:26 +02:00
|
|
|
<?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.
|
|
|
|
|
*
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
|
|
|
|
public function authorize(): bool
|
|
|
|
|
{
|
|
|
|
|
return auth('club')->check();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Prepare the data for validation.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function prepareForValidation(): void
|
|
|
|
|
{
|
2025-06-03 16:13:59 +02:00
|
|
|
/** @var array $coupons */
|
|
|
|
|
$coupons = $this->post('coupon');
|
2024-09-06 14:54:26 +02:00
|
|
|
$this->merge([
|
2025-06-03 16:13:59 +02:00
|
|
|
'coupon' => collect($coupons)
|
2024-09-06 14:54:26 +02:00
|
|
|
->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.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function attributes(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'coupon' => trans('coupon'),
|
|
|
|
|
'coupon.*' => trans('coupon'),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|