Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I render laravel mailable to variable

Tags:

laravel

I need to get the html of a Mailable class

$mail->html = (new InactivityReminder())->"do something to output the html"

There seems to be no toHtml method or something similar.

Mailable:

class InactivityReminder extends Mailable
{
    use Queueable, SerializesModels;

    public function __construct()
    {

    }

    public function build()
    {
        return $this->markdown('mail.it.inactivityReminder');
    }
}
like image 758
Chris Avatar asked Jan 04 '18 13:01

Chris


1 Answers

In 5.5 the render() method will render the view that you return in Mailable:

$html = (new InactivityReminder)->render()
like image 144
Alexey Mezenin Avatar answered Sep 30 '22 21:09

Alexey Mezenin