jdavidbakr / mail-tracker

Package for Laravel to inject tracking code into outgoing emails.
MIT License
570 stars 129 forks source link

how can I use this in the notification? #132

Closed janczakb closed 3 years ago

janczakb commented 3 years ago

Can you show me how I can use it in the code below?

<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class BillingNotification extends Notification
{
    use Queueable;
    private $billData;

    public function __construct($billData)
    {
        $this->billData = $billData;
    }

    public function via($notifiable)
    {
        return ['mail','database'];
    }

    public function toMail($notifiable)
    {
        return (new MailMessage)                    
            ->name($this->billData['name'])
            ->line($this->billData['body'])
            ->action($this->billData['text'], $this->billData['url'])
            ->line($this->billData['thanks']);
    }

    public function toArray($notifiable)
    {
        return [
            'bill_id' => $this->billData['bill_id']
        ];
    }    
}
jdavidbakr commented 3 years ago

Follow the instructions to install it in your project. It will work with notifications just fine.

janczakb commented 3 years ago

Follow the instructions to install it in your project. It will work with notifications just fine.

I installed it, I don't know how to configure it for notifications. can you show me an example on the above code?

jdavidbakr commented 3 years ago

There is nothing special to configure it for notifications.