From here : Laravel 5.4 - How to customize notification email layout?
I try customize notification email layout
My code to send email like this :
public function toMail($notifiable)
{
return (new MailMessage)
->subject('Test')
->view('vendor.mail.markdown.message',['data'=>$this->data]);
}
The view like this :
@component('mail::layout')
{{-- Header --}}
@slot('header')
@component('mail::header', ['url' => config('app.url')])
{{ config('app.name') }}
@endcomponent
@endslot
{{-- Body --}}
{{ $slot }} test
{{-- Subcopy --}}
@isset($subcopy)
@slot('subcopy')
@component('mail::subcopy')
{{ $subcopy }}
@endcomponent
@endslot
@endisset
{{-- Footer --}}
@slot('footer')
@component('mail::footer')
© {{ date('Y') }} {{ config('app.name') }}. All rights reserved.
@endcomponent
@endslot
@endcomponent
If the code executed, there exist error like this :
(2/2) ErrorException No hint path defined for [mail]. (View: C:\xampp\htdocs\myshop\resources\views\vendor\mail\markdown\message.blade.php)
How can I solve the error?
If you are using markdown in your template, you need to use the ->markdown()
method rather than the ->view()
method on your MailMessage
public function toMail($notifiable)
{
return (new MailMessage)
->subject('Test')
->markdown('vendor.mail.markdown.message', ['data' => $this->data]);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With