Installation
Requirements
Section titled “Requirements”- PHP ^8.2
- Laravel 10, 11, 12 or 13 (
illuminate/support,illuminate/database,illuminate/notifications) - PostgreSQL, MySQL 8.0.13+ or SQLite
The migration creates unique indexes over COALESCE(...) expressions (functional key parts). MySQL supports them from 8.0.13; MariaDB does not support them at all.
Install
Section titled “Install”composer require fomvasss/laravel-notify-templatesThe service provider and the NotifyTemplates facade alias are registered by package auto-discovery.
Publish and run the migrations:
php artisan vendor:publish --tag=notify-templates-migrationsphp artisan migrateEach migration is published only if a file with the same name suffix is not in database/migrations yet, so running the command again after an upgrade publishes only the new ones.
| Migration | Creates |
|---|---|
create_notifytemplates_tables | notify_templates, notify_role_subscriptions, notify_user_settings |
create_notify_logs_table | notify_logs — used only when the delivery log is enabled |
add_content_to_notify_logs_table | notify_logs.subject, notify_logs.body for 0.8.x installs; a no-op when the columns exist |
Publish the config if you need to change anything in it (optional):
php artisan vendor:publish --tag=notify-templates-configPublish the status label translations if you want to change them (optional):
php artisan vendor:publish --tag=notify-templates-langBind a recipient resolver
Section titled “Bind a recipient resolver”The package does not know your roles and users. If notifications are sent per role from event listeners, implement NotifyRoleResolverInterface and bind it — see Recipients & role subscriptions. The package itself never calls the resolver, so nothing breaks without a binding until your own code asks for it.
// AppServiceProvider::register()$this->app->bind( \Fomvasss\NotifyTemplates\Contracts\NotifyRoleResolverInterface::class, \App\Services\AppNotifyRoleResolver::class,);First notification
Section titled “First notification”php artisan notify:make OrderOrderedThis creates app/Notifications/OrderOrderedNotify.php. Fill in typeDefinition(), then create an active subscription for a role — nothing is sent for a regular type without one:
use Fomvasss\NotifyTemplates\Models\NotifyRoleSubscription;
NotifyRoleSubscription::create([ 'role_key' => 'client', 'notify_key' => 'OrderOrdered', 'is_active' => true, 'channels' => ['mail'],]);Next: Notify types and Sending notifications.