Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.8] Bug Fix: Render MailMessage if view method was used #29698

Merged
merged 1 commit into from Aug 23, 2019

Conversation

muhammetsait
Copy link
Contributor

MailMessage supports customizing its contents by setting lines of text or by using the view method to specify a custom template.

However, if you call view on MailMessage it will fail when calling render.

Steps to reproduce:

  • Create a notification php artisan make:notification InvoicePaid.

  • In the method toMail: return a new MailMessage with a custom view:

    public function toMail($notifiable)
    {
        return (new MailMessage)->view(
            'emails.name', ['invoice' => $this->invoice]
        );
    }
  • Add code to preview that notification:

    Route::get('mail', function () {
        $invoice = App\Invoice::find(1);
    
        return (new App\Notifications\InvoicePaid($invoice))
                    ->toMail($invoice->user);
    });

It will result in the following error: InvalidArgumentException View [] not found.

All code snippets were taken from https://laravel.com/docs/5.8/notifications
Specifically, formatting-mail-messages and previewing-mail-notifications sections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants