请注意:除了前面的答案之外,如果您想修改通知行 like You are receiving this...
等。以下是分步指南。
你需要覆盖默认值 https://laravel.com/docs/5.3/passwords#password-customization sendPasswordResetNotification
方法对你的User
model.
为什么?因为这些线是从Illuminate\Auth\Notifications\ResetPassword.php
。在核心中修改它意味着您的更改会在 Laravel 更新期间丢失。
为此,请将以下内容添加到您的User
model.
use App\Notifications\PasswordReset; // Or the location that you store your notifications (this is default).
/**
* Send the password reset notification.
*
* @param string $token
* @return void
*/
public function sendPasswordResetNotification($token)
{
$this->notify(new PasswordReset($token));
}
Lastly, 创建该通知 https://laravel.com/docs/5.3/notifications#creating-notifications:
php artisan make:notification PasswordReset
此通知内容的示例:
/**
* The password reset token.
*
* @var string
*/
public $token;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($token)
{
$this->token = $token;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Build the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->line('You are receiving this email because we received a password reset request for your account.') // Here are the lines you can safely override
->action('Reset Password', url('password/reset', $this->token))
->line('If you did not request a password reset, no further action is required.');
}