Skip to content

Events & Listeners ​

Modularous ships a set of events that fire at key points in the application lifecycle. Listeners react to those events and, when mail is enabled, automatically resolve and dispatch the matching notification class.

Events ​

ClassNamespaceFired When
ModelEventUnusualify\Modularous\EventsAbstract base — extended by all model-level events
ModularousUserRegisteringUnusualify\Modularous\EventsJust before a new user is persisted
ModularousUserRegisteredUnusualify\Modularous\EventsImmediately after a user is created
ModularousUserVerificationUnusualify\Modularous\EventsWhen an email-verification request is initiated
VerifiedEmailRegisterUnusualify\Modularous\EventsWhen a user completes registration via verified e-mail

Listeners ​

ClassNamespaceListens To
ListenerUnusualify\Modularous\ListenersAbstract base — extended by concrete listeners

Event Traits ​

All ModelEvent subclasses automatically gain the following traits:

TraitWhat it captures
EventChangesChanged model attributes and relationships
EventStateablePrevious / current stateable state
EventUrlsCurrent and previous HTTP request URLs
EventUserAuthenticated user at the time the event fired

SystemNotification Module Events ​

The SystemNotification module (in Modules\SystemNotification\Events\) defines a second set of domain events that fire on model lifecycle changes. These extend ModelEvent and are wired to their own listeners and notification classes:

EventFired When
ModelCreatedAny model is created
ModelUpdatedAny model is updated
ModelDeletedA model is soft-deleted
ModelRestoredA soft-deleted model is restored
ModelForceDeletedA model is permanently deleted
StateableUpdatedA model transitions state via HasStateable
AssignmentCreatedA new Assignment is created
AssignmentUpdatedAn existing Assignment is updated
PaymentCompletedA payment completes
PaymentFailedA payment fails
UnreadChatMessageUnread chat messages exist for a Chatable model

All these extend ModelEvent, so they automatically carry EventUser, EventUrls, EventChanges, and EventStateable context.

→ System Notifications — event/listener/notification map


Architecture Overview ​

[Action: model saved / user registers]
        │
        â–¼
  Event dispatched
  (ModelEvent subclass or user event)
        │
        â–¼
  Laravel event system
        │
        ├─► Listener::handle($event)
        │       └─ resolves {EventName}Notification
        │          sends mail if modularous.mail.enabled = true
        │
        └─► Broadcasting (ModelEvent only)
                broadcast on private channel: models.{model_id}
                broadcast on public channel:  model
                event name: modularous.{event_name}

→ Broadcasting guide