Search by

fomvasss / laravel-notify-templates

fomvasss

Notification templates management for Laravel: DB-based templates, role/user subscriptions, channel resolution.

Package info

github.com/fomvasss/laravel-notify-templates

pkg:composer/fomvasss/laravel-notify-templates

Statistics

Installs: 63

Dependents: 0

Suggesters: 0

Stars: 2

Open Issues: 0

0.13.0 2026-10-10 08:52 UTC

README

License Latest Stable Version Total Downloads

Database-driven notification templates for Laravel. Admins edit the subject and body of every notification per channel, role and tenant; the package picks the right template, resolves the delivery channels from role subscriptions and user preferences, and logs what was delivered — without tying you to a role package.

Українською

  • Templates in the database — per notify type × channel slot × role × tenant, with an 8-level fallback down to defaults in code
  • Type registry — notify types auto-discovered from app/Notifications, with metadata for an admin UI
  • Role subscriptions — which roles get which type, through which channels, with what delay
  • User preferences — turn a type off or narrow its channels per user; non-optional types for OTP codes
  • One via() chain for built-in and custom channels (Telegram, SMS, …) through a mapChannel() hook
  • Messenger buttons — link buttons under Telegram messages, multilingual
  • Delivery log — notify_logs with provider statuses sent → delivered → read

Requirements

  • PHP ^8.2
  • Laravel 10 – 13
  • PostgreSQL, MySQL 8.0.13+ or SQLite (not MariaDB)

Installation

composer require fomvasss/laravel-notify-templates

php artisan vendor:publish --tag=notify-templates-migrations
php artisan migrate

Quick start

php artisan notify:make OrderOrdered
use Fomvasss\NotifyTemplates\Notifications\BaseNotify;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;

final class OrderOrderedNotify extends BaseNotify implements ShouldQueue
{
    use Queueable;

    public function __construct(protected Order $order, protected string $roleKey) {}

    public static function typeDefinition(): array
    {
        return [
            'key' => 'OrderOrdered',
            'name' => 'Order placed',
            'group' => 'order',
            'defaults' => [
                'mail' => ['subject' => 'Order placed', 'body' => 'Your order [order:number] has been received.'],
            ],
        ];
    }

    protected function prepareText(string $text, mixed $notifiable): string
    {
        return str_replace('[order:number]', $this->order->number, $text);
    }
}
use Fomvasss\NotifyTemplates\Models\NotifyRoleSubscription;

NotifyRoleSubscription::create(['role_key' => 'client', 'notify_key' => 'OrderOrdered', 'channels' => ['mail']]);

$user->notify(new OrderOrderedNotify($order, 'client'));

Documentation

Online: https://fomvasss.github.io/laravel-notify-templates/ — the same pages as in docs/.

License

MIT — see LICENSE.