@tykus I did it in the same you mentioned but still the header file is not getting this $logo variable. Attaching full code for all 3 files.
SendInvoiceToCustomerNotification.php
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\HtmlString;
class SendInvoiceToCustomerNotification extends Notification implements ShouldQueue
{
use Queueable;
public $emailContent, $pdf,$invoice;
/**
* Create a new notification instance.
*/
public function __construct($emailContent, $pdf,$invoice)
{
$this->emailContent = $emailContent;
$this->pdf = base64_encode($pdf);
$this->invoice = $invoice;
}
/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*/
public function toMail(object $notifiable): MailMessage
{
//Config::set('app.application_logo', getEmailTemplateLogo($this->invoice->business));
return (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',
])
->with([
'logo' => getEmailTemplateLogo($this->invoice->business)
]);
}
/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
//
];
}
}
message.blade.php
<x-mail::layout>
{{-- Header --}}
<x-slot:header>
<x-mail::header :url="config('app.url')" :logo="$logo ?? Vite::asset('resources/images/logo.svg')">
{{ config('app.name') }}
</x-mail::header>
</x-slot:header>
{{-- Body --}}
{{ $slot }}
{{-- Subcopy --}}
@isset($subcopy)
<x-slot:subcopy>
<x-mail::subcopy>
{{ $subcopy }}
</x-mail::subcopy>
</x-slot:subcopy>
@endisset
{{-- Footer --}}
<x-slot:footer>
<x-mail::footer>
© {{ date('Y') }} {{ config('app.name') }}. {{ __('All rights reserved.') }}
</x-mail::footer>
</x-slot:footer>
</x-mail::layout>
header.blade.php
@props(['url', 'logo'])
{{-- @dd($logo) --}}
<tr>
<td class="header">
<a href="{{ $url }}" style="display: inline-block;">
<img src="{{ $logo }}" class="logo" alt="{{ config('app.name') }}" style="width:100px;">
</a>
</td>
</tr>
Thanks