itmosoft / laravel-notifications
Database-backed notification records and delivery tracking for Laravel applications, with polymorphic notifiables and configurable channels.
Requires
- php: ^8.3
- illuminate/contracts: ^12.0 || ^13.0
- illuminate/database: ^12.0 || ^13.0
- illuminate/support: ^12.0 || ^13.0
Requires (Dev)
- orchestra/testbench: ^10.0 || ^11.0
- phpunit/phpunit: ^11.0 || ^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Database-backed notification records and delivery-state tracking for Laravel 12 and 13.
Features
- Polymorphic notifications for any Eloquent model using the
Notifiabletrait. - 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;
databaseis 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_daysis 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.