Laravel 5.7 尝试发送密码重置链接时查看文件中未定义的变量令牌



>我已经做了一个自定义通知,用于发送密码重置链接和 邮件的自定义刀片,但我不知道如何将令牌变量传递到myPasswordNotification.blade

中用户.php

use AppNotificationsmyPasswordResetNotification;
public function sendPasswordResetNotification($token)
{
$this->notify(new myPasswordResetNotification($token));
}

我的密码重置通知.php

namespace AppNotifications;
use IlluminateBusQueueable;
use IlluminateNotificationsNotification;
use IlluminateContractsQueueShouldQueue;
use IlluminateNotificationsMessagesMailMessage;
class myPasswordResetNotification extends Notification
{
use Queueable;
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'];
}
/**
* Get the mail representation of the notification.
*
* @param  mixed  $notifiable
* @return IlluminateNotificationsMessagesMailMessage
*/
public function toMail($notifiable)
{
return   new(MailMessage)->markdown('notifications.users.myPasswordNotification');
}
}

myPasswordNotification.blade.php

@component('mail::button', ['url' => route('password.reset', $token)])

我将 toMail 函数更改为此函数,现在它似乎可以正常工作。

public function toMail($notifiable)
{
$url = route('password.reset',$this->token);
return (new MailMessage)->markdown('notifications.users.myPasswordNotification',['url'=> $url]);
}

我把myPasswordNotification.blade.php改成了这个。

@component('mail::button', ['url' => $url])

最新更新