Custom properties in notifications Hi,
I'd like to add custom properties in laravel notifications (laravel 12). I tried with :
...
$message = (new MailMessage)
->line('The introduction to the notification.')
->action('Notification Action', url('/'))
->line('Thank you for using our application!')
;
$message->viewData['logo'] = 'https://dummyimage.com/200x60/ccc/000.png&text=DEMO+LOGO';
...
and
<x-mail::header :url="config('app.url')" :logo="$logo" :alt="$alt">
{{ config('app.name') }}
</x-mail::header>
But it doesn't works. I tried with @props and it doesn't works to.
Anyone can help me ?
You can try like this:
return (new MailMessage)
->subject('Test')
->markdown('mail.custom-notification', [
'logo' => 'https://dummyimage.com/200x60/ccc/000.png&text=DEMO+LOGO',
]);
and in the blade:
x-mail::message
Hello
Thanks for using our application!
<x-mail::button :url="url('/')">
Action
</x-mail::button>
</x-mail::message>
it works if I specify props in email.blade.php
<x-mail::message :logo="$logo">
...
</x-mail:message>
in message.blade.php
<x-mail::layout>
{{-- Header --}}
<x-slot:header>
<x-mail::header :url="config('app.url')" :logo="$logo">
...
</x-mail:header>
</x-slot:header>
...
</x-mail:layout>
in notification
$message->viewData['logo'] = 'https://dummyimage.com/200x60/ccc/000.png&text=DEMO+LOGO';
But it requires a lot of manipulation for very little.
Please sign in or create an account to participate in this conversation.