TerrePorter / StringBladeCompiler

Render Blade templates from string
MIT License
175 stars 76 forks source link

Compiler not working in queues #77

Closed Sauruz closed 3 years ago

Sauruz commented 3 years ago

Hi terreporter, great package! There's a problem i'm facing and don't know how to solve it.
I'm using compiled strings in my mailables like this:

$template->body = view (['template' => $template->body], ['member' => $member->toArray()]);

this works fine when sending mail like this:

Mail::to($member->email)->send(new MemberMail($member));

however the variables in the template are not rendered when sending the mail using queues like this

Mail::to($member->email)->queue(new MemberMail($member));

Any solutions?

Sauruz commented 3 years ago

Nevermind, this is the way Laravel handles queues. $template is a model in my application. When you change the the model ($template->body) it's not changed in the DB. The queue fetches the model from te DB so it wont have the rendered body.