How to send mail through whatever the text of the letter was formed before that in the queue?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
8 views
When sending an email through Laravel

Mail::to($email)->queue(new \\App\\Mail\otifyReserveCreated($reserve, true));

themselves the texts of the letters are formed already in the process queue. And if there is passed a Laravel model - she is saved and restored in the queue. But sometimes, you delete the model, even before the letter went, and eventually the error occurs.

How can you (regular means larabel) to send letters so that the text was formed even before that in the queue ?
by | 8 views

2 Answers

0 like 0 dislike
Instead of the model pass the generated text or other required data.
by
0 like 0 dislike
2 options:
1) make your message class, which will save in the field class the text of the letter $this->content = (string)view('mails.message', $data).
2) to convey the message class not the model object, but only an array with the desired attributes $model->toArray()/getAttributes(), for example.

Most likely you are using an admixture SerializesModels, which contains the logic for serializing (suddenly) model. It actually saves only the ID and type of the model, and subsequently this data restores the entire model.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
35,457 users