Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I solve "No hint path defined for [mail]." (customize email layout) on laravel?

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?

like image 283
moses toh Avatar asked Sep 04 '17 07:09

moses toh


1 Answers

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]);
}
like image 109
Joe Avatar answered Nov 18 '22 17:11

Joe