Skip to content

Commit

Permalink
Add ability to set theme for mail notifications
Browse files Browse the repository at this point in the history
We already can set a different theme than the default one for our
Mailable. It would be very useful if there was a way to set the theme
for the mail notifications too.
  • Loading branch information
Giulio Troccoli-Allard committed Jul 10, 2019
1 parent a5bf6ab commit dfb7ef5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Illuminate/Notifications/Channels/MailChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ protected function buildView($message)
return $message->view;
}

if (property_exists($message, 'theme') && ! is_null($message->theme)) {
$this->markdown->theme($message->theme);
}

return [
'html' => $this->markdown->render($message->markdown, $message->data()),
'text' => $this->markdown->renderText($message->markdown, $message->data()),
Expand Down
20 changes: 20 additions & 0 deletions src/Illuminate/Notifications/Messages/MailMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ class MailMessage extends SimpleMessage implements Renderable
*/
public $markdown = 'notifications::email';

/**
* The current theme being used when generating emails.
*
* @var string|null
*/
public $theme = 'default';

/**
* The "from" information for the message.
*
Expand Down Expand Up @@ -134,6 +141,19 @@ public function template($template)
return $this;
}

/**
* Set the theme to use with the markdown template.
*
* @param string $theme
* @return $this
*/
public function theme($theme)
{
$this->theme = $theme;

return $this;
}

/**
* Set the from address for the mail message.
*
Expand Down

0 comments on commit dfb7ef5

Please sign in to comment.