Looking to hire Laravel developers? Try LaraJobs

laravel-notifications maintained by itmosoft

Description
Database-backed notification records and delivery tracking for Laravel applications, with polymorphic notifiables and configurable channels.
Last update
2026/11/14 16:13 (dev-main)
License
Links
Downloads
3

Comments
comments powered by Disqus

ITMOSOFT Laravel Notifications

Database-backed notification records and delivery-state tracking for Laravel 12 and 13.

Features

  • Polymorphic notifications for any Eloquent model using the Notifiable trait.
  • Read/unread state and bulk mark-as-read.
  • Delivery and failure timestamps with an optional failure reason.
  • Configurable notification table name and prefix.
  • Configurable enabled channels; database is the only built-in persistence channel.
  • Laravel package auto-discovery.

Requirements

  • PHP 8.3+
  • Laravel 12 or 13

Installation

composer require itmosoft/laravel-notifications
php artisan vendor:publish --tag=itmosoft-notifications-config
php artisan migrate

The package migration is loaded automatically. The config file is optional.

Usage

Add the trait to a notifiable model:

use Illuminate\Foundation\Auth\User as Authenticatable;
use ItmoSoft\Notifications\Concerns\Notifiable;

class User extends Authenticatable
{
    use Notifiable;
}

Create a notification:

$notification = $user->notify(
    ['title' => 'Order shipped', 'order_id' => 123],
    type: 'order_shipped',
);

Or use the manager:

use ItmoSoft\Notifications\NotificationManager;

$notification = app(NotificationManager::class)->send(
    $user,
    ['title' => 'Your order is on its way'],
    type: 'order_shipped',
);

Read state:

$user->unreadNotifications;
$user->readNotifications;
$notification->markAsRead();
$notification->markAsUnread();
$user->markAllNotificationsAsRead();

Delivery state:

$notification->markAsDelivered();
$notification->markAsFailed('SMTP provider unavailable');

Delete all notifications for a model:

$user->deleteNotifications();

Configuration

return [
    'table' => 'itmosoft_notifications',
    'prefix' => '',
    'default_channel' => 'database',
    'channels' => ['database'],
    'prune_after_days' => 90,
];

channels is an allowlist for the manager. This release persists notification records in the database only; it does not send email, SMS, push, Slack, or other external messages. External delivery adapters and queue orchestration should be implemented by the consuming application or a future package release.

Important design notes

  • The package stores arbitrary JSON data. Do not put passwords, access tokens, payment credentials, or other secrets in notification payloads.
  • The package does not automatically register model observers or dispatch jobs.
  • The application remains responsible for authorization, tenant scoping, retention scheduling, and external delivery.
  • prune_after_days is a configuration value for application retention policy; this release does not register a pruning command.
  • The migration uses UUID notification IDs and polymorphic notifiable columns.
  • For high-volume systems, use queued delivery and retention jobs, and evaluate database indexes against your actual query patterns.

Testing

composer validate --strict
composer install
composer test

License

MIT. See LICENSE.