What problem does it solve?
It solves the problem of building maintainable, reliable Laravel notifications that reach users through multiple channels (mail, database, broadcast, and more) without duplicating logic or missing key production concerns like queuing, conditional sending, and testing.
Core Features & Use Cases
- Multi-channel delivery: Use
via() to send notifications over channels such as mail, database, and broadcast from a single notification class.
- Channel-specific formatting: Implement
toMail(), toArray(), toBroadcast(), and additional channel methods (e.g., Slack) so each medium receives the right payload.
- Production-ready behavior: Enable queueing with
ShouldQueue and Queueable, support afterCommit, configure per-channel queues with viaQueues(), and add retry/failure handling.
- Data persistence and broadcasting: Store only serializable values in
toArray() for database notifications and emit broadcast payloads via BroadcastMessage.
- Targeting and delivery controls: Use
shouldSend() for per-notifiable/per-channel decisions and support on-demand recipients using Notification::route().
- Testing and quality checks: Use
Notification::fake() with assertions for sent/not-sent notifications and validate mail content.
Quick Start
Create a notification class that uses via() to return mail, database, and broadcast, then implement toMail() for the email content and toArray() for the database payload.