feat(notification): implement email notifications for user registration and purchase events

This commit is contained in:
2026-07-22 09:54:19 -03:00
parent 7e1ffbf417
commit 528772fc96
19 changed files with 450 additions and 10 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Domains\Ticket\Listeners;
use App\Domains\Catalog\Models\CatalogItem;
use App\Domains\Notification\Events\TicketsAvailable;
use App\Domains\Purchase\Events\PurchasePaid;
use App\Domains\Ticket\Exceptions\TicketGenerationException;
use App\Domains\Ticket\Services\TicketGeneratorService;
@@ -20,6 +21,7 @@ class GenerateTicketsForPaidPurchase
->with(['user', 'items'])
->findOrFail($event->purchase->getKey());
$user = $purchase->user;
$ticketIds = [];
foreach ($purchase->items as $purchaseItem) {
$catalogItem = CatalogItem::query()
@@ -38,12 +40,18 @@ class GenerateTicketsForPaidPurchase
throw TicketGenerationException::purchaseWithoutUser($purchase);
}
$this->ticketGenerator->generate(
$generatedTickets = $this->ticketGenerator->generate(
$catalogItem,
$user,
$purchaseItem->cantidad,
$purchaseItem->source_variant_id,
);
array_push($ticketIds, ...$generatedTickets->pluck('id')->all());
}
if ($ticketIds !== []) {
TicketsAvailable::dispatch($purchase, $ticketIds);
}
}