Skip to content

Commit

Permalink
allow customization of mail message building
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Dec 27, 2017
1 parent ee0a5ff commit 6535186
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Illuminate/Auth/Notifications/ResetPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ class ResetPassword extends Notification
*/
public $token;

/**
* The callback that should be used to build the mail message.
*
* @var \Closure|null
*/
public static $toMailCallback;

/**
* Create a notification instance.
*
Expand Down Expand Up @@ -44,9 +51,24 @@ public function via($notifiable)
*/
public function toMail($notifiable)
{
if (static::$toMailCallback) {
return call_user_func(static::$toMailCallback, $notifiable, $this->token);
}

return (new MailMessage)
->line('You are receiving this email because we received a password reset request for your account.')
->action('Reset Password', url(config('app.url').route('password.reset', $this->token, false)))
->line('If you did not request a password reset, no further action is required.');
}

/**
* Set a callback that should be used when building the notification mail message.
*
* @param \Closure $callback
* @return void
*/
public static function toMailUsing($callback)
{
static::$toMailCallback = $callback;
}
}

0 comments on commit 6535186

Please sign in to comment.