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> */ 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'), ]; } }