<?php
namespace App\Providers;
use App\Modules\Order\Events\OrderPlaced;
use App\Modules\Order\Events\OrderStatusChanged;
use App\Modules\Order\Listeners\SendOrderNotificationEmail;
use App\Modules\Order\Listeners\SendOrderPlacedEmail;
use App\Modules\Pharmacy\Events\PrescriptionStatusChanged;
use App\Modules\Pharmacy\Listeners\SendPrescriptionStatusEmail;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* Event → Listener mappings.
*/
protected $listen = [
// AuthService::register() fires Registered on every new signup, but
// shouldDiscoverEvents() below is false (auto-discovery off) and
// this custom $listen array never carried Laravel's standard
// Registered -> SendEmailVerificationNotification mapping — the one
// that normally ships in a fresh app's EventServiceProvider. Net
// effect: the Registered event fired every time, nothing was
// listening, and no verification email was ever sent on signup.
// Users only got an email if they explicitly clicked "Resend".
Registered::class => [
SendEmailVerificationNotification::class,
],
// Fired immediately when a new order is created (status = pending)
OrderPlaced::class => [
SendOrderPlacedEmail::class,
],
// Fired on every status transition (confirmed, shipped, delivered, cancelled, refunded)
OrderStatusChanged::class => [
SendOrderNotificationEmail::class,
],
// Fired when a pharmacist approves or rejects a prescription
PrescriptionStatusChanged::class => [
SendPrescriptionStatusEmail::class,
],
];
public function boot(): void
{
parent::boot();
}
/**
* Determine if events and listeners should be auto-discovered.
*/
public function shouldDiscoverEvents(): bool
{
return false;
}
}