我只是想在注册后更改默认身份验证的 toMail() 函数中的 ->greeting() 通知。我想保留验证 URL 等。但我被卡住了。如果我覆盖 sendEmailVerificationnotification() ,则整个邮件都会更改。如何获取原本应该发送的 URL 或如何编辑原始身份验证以仅编辑 ->greeting('Hello') 与 Dear Name, ?
在用户模型中
public function sendEmailVerificationNotification()
{
$this->notify(new CustomVerifyEmail());
}
在 CustomVerifyEmail 中
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct()
{
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
//dd($notifiable);
return (new MailMessage)
->greeting('Dear ' . $notifiable->name . ',')
->line('The introduction to the notification.')
->action('Notification Action', url())
->line('Thank you for using our application!');
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}