From 78fa6f2c758e929233889103e2f709d0017c7598 Mon Sep 17 00:00:00 2001 From: Philip Iezzi <2759561+onlime@users.noreply.github.com> Date: Mon, 18 Dec 2023 16:56:07 +0100 Subject: [PATCH] [10.x] Add `MailMessage` helpers for plain text email notifications (#49407) * Add helper methods to MailMessage for plain text view and raw body * Improve MailMessage view helpers, respecting previous view value * formatting --------- Co-authored-by: Taylor Otwell --- .../Notifications/Messages/MailMessage.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Illuminate/Notifications/Messages/MailMessage.php b/src/Illuminate/Notifications/Messages/MailMessage.php index d847072c8f59..280f2e1f2e2e 100644 --- a/src/Illuminate/Notifications/Messages/MailMessage.php +++ b/src/Illuminate/Notifications/Messages/MailMessage.php @@ -129,6 +129,21 @@ public function view($view, array $data = []) return $this; } + /** + * Set the plain text view for the mail message. + * + * @param string $textView + * @param array $data + * @return $this + */ + public function text($textView, array $data = []) + { + return $this->view([ + 'html' => is_array($this->view) ? ($this->view['html'] ?? null) : $this->view, + 'text' => $textView, + ], $data); + } + /** * Set the Markdown template for the notification. *