New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

tkaratug/laravel-notification-event-subscriber

This is my package laravel-notification-event-subscriber
15,470 91
Install
composer require tkaratug/laravel-notification-event-subscriber
Latest Version:1.4.0
PHP:^8.1 | ^8.2 | ^8.3
Laravel:9 · 10 · 11
License:MIT
Last Updated:Dec 18, 2024
Links: GitHub  ·  Packagist
Maintainer: tkaratug

image

Laravel Notification Event Subscriber

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package allows you to run any kind of actions while a notification is being sent or after it has been sent using onSent() and onSending() methods.

It registers an event subscriber NotificationEventSubscriber and listens to the NotificationSent and NotificationSending events of Laravel. When one of them is fired, the event subscriber runs a defined method according to the event.

Installation

You can install the package via composer:

composer require tkaratug/laravel-notification-event-subscriber

Usage

namespace App\Notifications;

use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\Log;

class UserRegisteredNotification extends Notification
{   
    public function via($notifiable): array
    {
        return ['mail'];
    }
    
    public function toMail($notifiable): MailMessage
    {
        return (new MailMessage)
                    ->greeting('foo')
                    ->line('bar');
    }
    
    public function onSending($notifiable, $channel, $response = null): void
    {
        Log::info($this::class . ' is being sent to  via ' . $channel);
    }
    
    public function onSent($notifiable, $channel): void
    {
        Log::info($this::class . ' has been sent to  via ' . $channel);
    }
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

tkaratug/livewire-smart-table

An advanced datatable component for Laravel Livewire

2,392 92
tkaratug/laravel-domain-whitelist

A domain wwhitelist checker middleware.

1,235 13
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

648,266,899 9,701
laravel/framework

The Laravel Framework.

604,216,237 34,982
laravel/tinker

Powerful REPL for the Laravel framework.

512,508,631 7,443

Version History

Version Released PHP Laravel License
1.4.0 ^8.1 | ^8.2 | ^8.3 ^9.0 | ^10.0 | ^11.0 MIT
1.3.0 ^8.1 | ^8.2 ^9.0 | ^10.0 MIT
1.2.0 ^8.1 ^9.0 MIT
1.1.0 ^8.1 ^9.0 MIT
1.0.0 ^8.1 ^9.0 MIT