• Czas czytania ~1 min
  • 21.02.2023

Laravel Notification Event Subscriber to prosty pakiet, który rejestruje subskrybenta wydarzenia, aby ułatwić uruchamianie kodu podczas wysyłania powiadomień.

W szczególności ten pakiet umożliwia uruchamianie dowolnej akcji podczas wysyłania powiadomienia lub po jego wysłaniu:

use Illuminate\Support\Facades\Log;

class UserRegisteredNotification extends Notification
{
    /* ...Notification code... */

    // Handlers for sending/sent events.
    public function onSending(string $channel, $response = null): void
    {
        Log::info($this::class . ' is being sent via ' . $channel);
    }
    public function onSent(string $channel): void
    {
        Log::info($this::class . ' has been sent via ' . $channel);
    }
}

Działa poprzez zarejestrowanie subskrybenta zdarzeń, który nasłuchuje zdarzeń NotificationSending i NotificationSent, który sprawdza, czy klasa powiadomień definiuje metodę onSending lub onSent.

Jeśli chcesz dowiedzieć się więcej o tym pakiecie, sprawdź go na GitHub pod adresem laravel-notification-event-subscriber.

Comments

No comments yet
Yurij Finiv

Yurij Finiv

Full stack

O

Professional Fullstack Developer with extensive experience in website and desktop application development. Proficient in a wide range of tools and technologies, including Bootstrap, Tailwind, HTML5, CSS3, PUG, JavaScript, Alpine.js, jQuery, PHP, MODX, and Node.js. Skilled in website development using Symfony, MODX, and Laravel. Experience: Contributed to the development and translation of MODX3 i...

O autorze CrazyBoy49z
WORK EXPERIENCE
Kontakt
Ukraine, Lutsk
+380979856297