From 6535186b0f71a6b0cc2d8a821f3de209c05bcf4f Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 27 Dec 2017 16:12:37 -0600 Subject: [PATCH] allow customization of mail message building --- .../Auth/Notifications/ResetPassword.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Illuminate/Auth/Notifications/ResetPassword.php b/src/Illuminate/Auth/Notifications/ResetPassword.php index cd1ca8661d15..a87983b37a27 100644 --- a/src/Illuminate/Auth/Notifications/ResetPassword.php +++ b/src/Illuminate/Auth/Notifications/ResetPassword.php @@ -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. * @@ -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; + } }