PHP code example of tkaratug / laravel-notification-event-subscriber

1. Go to this page and download the library: Download tkaratug/laravel-notification-event-subscriber library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tkaratug / laravel-notification-event-subscriber example snippets


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);
    }
}