validate([ 'code' => ['required', 'string'], 'recipient_only' => ['sometimes', 'boolean'], 'locale' => ['nullable', 'string'], 'schedule_at' => ['nullable', 'date'], ]); $voucher = GiftVoucher::query() ->where('code', strtoupper($data['code'])) ->first(); if (! $voucher) { throw ValidationException::withMessages([ 'code' => __('Voucher not found.'), ]); } if (! empty($data['schedule_at'])) { $this->vouchers->scheduleRecipientDelivery($voucher, now()->parse($data['schedule_at']), $data['locale'] ?? app()->getLocale()); } else { $this->vouchers->resend($voucher, $data['locale'] ?? app()->getLocale(), $data['recipient_only'] ?? null); } return response()->json([ 'status' => 'ok', ]); } }