Back to feed
Dev.to
Dev.to
7/2/2026
The original title is 11 words: "Eloquent Events vs Domain Events: Why the Framework Hook Isn't Enough"

The original title is 11 words: "Eloquent Events vs Domain Events: Why the Framework Hook Isn't Enough"

Original: Eloquent Events vs Domain Events: Why the Framework Hook Isn't Enough

Short summary

Laravel's Eloquent ORM hooks (saved, updated) fire on database persistence, not business intent, causing bugs like duplicate emails or bogus receipts. Domain events—named for actual business operations and raised by aggregates—capture intent explicitly with invariant checks, preventing ORM-hook failures.

  • Eloquent events fire on row persistence, not business meaning; wasChanged() inspection can't distinguish cache touches from real state changes
  • Domain events name actual business operations (PaymentWasConfirmed) and are raised by business logic with invariant guards, not the ORM
  • Recording events in aggregates prevents bugs ORM hooks can't catch—confirmPayment() throws if the order state is invalid

Generated with AI, which can make mistakes.

Is this a good recommendation for you?

Comments

Failed to load comments. Please try again.

Explore more