agentsclimarketplace

Laravel notifications

Skill event4u-app/agent-config/dist/agent-src/skills/laravel-notifications

Use when sending notifications via mail, Slack, database, or custom channels — with queuing, on-demand recipients, and notification preferences.From its SKILL.md

Install
npx -y skills add event4u-app/agent-config --skill laravel-notifications

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 19 stars19 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

4.8 KB, ~1.0k tokens by cl100k_base, as published. Nobody here has run it

laravel-notifications

When to use

Use this skill when sending notifications to users or external systems:

  • Email, Slack, SMS, or DB notifications
  • Custom notification channels
  • On-demand notifications (to non-user recipients)
  • Notification preferences and opt-out logic

For Mailables (complex email templates, attachments), see laravel-mail.

Procedure: Create a notification

  1. Generate class — php artisan make:notification InvoiceCreated.
  2. Choose channels — Mail, DB, Slack, or custom. Implement via().
  3. Build content — Implement toMail(), toArray(), etc. for each channel.
  4. Queue it — Add ShouldQueue interface for non-blocking delivery.
  5. Verify — Send test notification, confirm delivery on all channels.

Example

php artisan make:notification InvoiceCreated
class InvoiceCreated extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct(
        private readonly Invoice $invoice,
    ) {}

    /** @return array<int, string> */
    public function via(object $notifiable): array
    {
        return ['mail', 'database'];
    }

    public function toMail(object $notifiable): MailMessage
    {
        return (new MailMessage())
            ->subject('New Invoice #' . $this->invoice->getNumber())
            ->greeting('Hello ' . $notifiable->getName())
            ->line('A new invoice has been created.')
            ->action('View Invoice', url('/invoices/' . $this->invoice->getId()))
            ->line('Thank you for your business.');
    }

    /** @return array<string, mixed> */
    public function toArray(object $notifiable): array
    {
        return [
            'invoice_id' => $this->invoice->getId(),
            'amount' => $this->invoice->getAmount(),
        ];
    }
}

Sending notifications

// Via the Notifiable trait on the model
$user->notify(new InvoiceCreated($invoice));

// Via the Notification facade (multiple recipients)
Notification::send($users, new InvoiceCreated($invoice));

// On-demand (no user model needed)
Notification::route('mail', '[email protected]')
    ->route('slack', '#billing')
    ->notify(new InvoiceCreated($invoice));

Database notifications

Requires the notifications table migration:

php artisan notifications:table
php artisan migrate
// Read notifications
$user->notifications;           // all
$user->unreadNotifications;     // unread only

// Mark as read
$notification->markAsRead();
$user->unreadNotifications->markAsRead();

Slack notifications

public function toSlack(object $notifiable): SlackMessage
{
    return (new SlackMessage())
        ->text('Invoice #' . $this->invoice->getNumber() . ' created')
        ->headerBlock('New Invoice')
        ->sectionBlock(function (SectionBlock $block) {
            $block->text('Amount: ' . $this->invoice->getAmount());
        });
}

Notification preferences

public function via(object $notifiable): array
{
    // Respect user preferences
    $channels = ['database'];

    if ($notifiable->wantsEmailNotifications()) {
        $channels[] = 'mail';
    }

    if ($notifiable->wantsSlackNotifications()) {
        $channels[] = 'slack';
    }

    return $channels;
}

Core rules

  • Always queue notifications — implement ShouldQueue to avoid blocking requests.
  • Keep payloads small in toArray() — store IDs, not full objects.
  • Use via() for channel logic — don't hardcode channels, respect user preferences.
  • On-demand for external recipients — use Notification::route() for non-user targets.
  • Database notifications for in-app — use the notifications table for in-app notification centers.

Output format

  1. Notification class with via() and channel-specific methods
  2. Queued dispatch with proper serialization

Auto-trigger keywords

  • notification
  • notify
  • Notifiable
  • MailMessage
  • SlackMessage
  • DB notification

Gotcha

  • Don't send notifications synchronously in request lifecycle — always queue them.
  • The model forgets to implement toArray() for DB notifications — it throws silently.
  • via() method must return an array even for a single channel — return ['mail'], not return 'mail'.

Do NOT

  • Do NOT store large objects in DB notification data — use IDs and fetch on read.
  • Do NOT use notifications for complex emails — use Mailables instead.

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 610,677. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.