Skip to content

Commit 6535186

Browse files
committed
allow customization of mail message building
1 parent ee0a5ff commit 6535186

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Diff for: src/Illuminate/Auth/Notifications/ResetPassword.php

+22
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ class ResetPassword extends Notification
1414
*/
1515
public $token;
1616

17+
/**
18+
* The callback that should be used to build the mail message.
19+
*
20+
* @var \Closure|null
21+
*/
22+
public static $toMailCallback;
23+
1724
/**
1825
* Create a notification instance.
1926
*
@@ -44,9 +51,24 @@ public function via($notifiable)
4451
*/
4552
public function toMail($notifiable)
4653
{
54+
if (static::$toMailCallback) {
55+
return call_user_func(static::$toMailCallback, $notifiable, $this->token);
56+
}
57+
4758
return (new MailMessage)
4859
->line('You are receiving this email because we received a password reset request for your account.')
4960
->action('Reset Password', url(config('app.url').route('password.reset', $this->token, false)))
5061
->line('If you did not request a password reset, no further action is required.');
5162
}
63+
64+
/**
65+
* Set a callback that should be used when building the notification mail message.
66+
*
67+
* @param \Closure $callback
68+
* @return void
69+
*/
70+
public static function toMailUsing($callback)
71+
{
72+
static::$toMailCallback = $callback;
73+
}
5274
}

0 commit comments

Comments
 (0)