Skip to content

How to pass custom variables in Laravel notifications? #55881

Closed Answered by DhPandya
DhPandya asked this question in Q&A
Discussion options

You must be logged in to vote

Link for the original discussion

Notification Class

$message = (new MailMessage)
            ->subject($this->emailContent['subject'])
            ->line(new HtmlString($this->emailContent['email_body']))
            ->action('Pay Invoice', url('/'))
            ->line('Thank you for using our application!')
            ->attachData(base64_decode($this->pdf), 'invoice.pdf', [
                'mime' => 'application/pdf',
            ]);
        $message->viewData['logo'] = getEmailTemplateLogo($this->invoice->business);
        return $message;

resources/views/vendor/notifications/email.blade.php
<x-mail::message :logo="$logo">

This works like a charm! No additional views no custom coding…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by DhPandya
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant