laravel-notification-patterns

Implements Laravel notifications across mail, database, broadcast, and Slack channels with queueing.

1|Updated Jan 10, 2024
One-click install
npx skills add https://github.com/noemdb/cfla --skill laravel-notification-patterns-noemdb
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: laravel-notification-patterns
Source: https://github.com/noemdb/cfla/tree/main/.claude/skills/laravel-notification-patterns
Command: npx skills add https://github.com/noemdb/cfla --skill laravel-notification-patterns-noemdb

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building reliable notification systems in Laravel requires coordinating multiple delivery channels, queue configuration, conditional sending logic, and testing strategies, which is error-prone when done from scratch. ## Core Features & Use Cases - Multi-Channel Delivery: Send notifications via mail, database, broadcast, Slack, and custom channels like SMS from a single notification class. - Queueing and Reliability: Configure per-channel queues, delayed delivery, after-commit dispatching, retries, and failure handling for queued notifications. - Testing Support: Verify notification delivery and mail content using Notification::fake() assertions. - Use Case: When an order ships in an e-commerce application, send a queued email with tracking details, store a database notification for the user's inbox, and broadcast a real-time update, all from one OrderShipped notification class. ## Quick Start Create a Laravel notification class that sends an order shipped message via mail and database channels with queueing enabled.

Frequently Asked Questions about laravel-notification-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I send Laravel notifications to multiple channels?▼

Define the channels in the notification's via() method by returning an array like ['mail', 'database', 'broadcast']. Then implement the corresponding toMail(), toArray(), and toBroadcast() methods to format the message for each channel.

How to queue Laravel notifications for better performance?▼

Implement the ShouldQueue interface on the notification class and use the Queueable trait. You can assign different queues per channel with viaQueues(), delay delivery per channel, and set afterCommit to dispatch only after database transactions commit.

Can I send Laravel notifications without a user model?▼

Yes, use on-demand notifications with Notification::route('mail', 'admin@example.com')->notify(new YourNotification()). This supports mail and Slack routes and allows specifying recipient names without requiring a Notifiable model.

How do I test Laravel notifications without sending them?▼

Call Notification::fake() in your test, then use assertions like Notification::assertSentTo(), assertNotSentTo(), and assertSentToTimes() to verify delivery. You can also inspect mail content by calling toMail() directly and asserting on the subject and rendered output.

How do I conditionally send a Laravel notification?▼

Implement the shouldSend() method on the notification class, which receives the notifiable and channel name. Return false to skip delivery, for example to respect user email preferences or suppress notifications below a threshold amount.