0

在进行密码重置时,我将在 URL 中附加用户的电子邮件地址,因此重置 url 看起来像这样http://blog.dev/password/reset/4cfbb048346474aab7080c88f16c34b9ea377b9ea35804387216fce303a38855?email=test%40gmail.com

但是我得到了错误FatalErrorException in CustomResetPassword.php line 54: Call to undefined method App\Notifications\CustomResetPassword::getEmailForPasswordReset()

我正在通过自定义通知类发送重置电子邮件,代码如下

namespace App\Notifications;


use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;


class CustomResetPassword 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 \Illuminate\Notifications\Messages\MailMessage
 */
public function toMail($notifiable)
{
     return (new MailMessage)
        ->subject('Reset Password')
        ->line('You are receiving this email because we received a password reset request for your account.')
        ->action('Reset Password', url('password/reset', $this->token).'?email='.urlencode($this->getEmailForPasswordReset()))
        ->line('If you did not request a password reset, no further action is required.');
}

/**
 * Get the array representation of the notification.
 *
 * @param  mixed  $notifiable
 * @return array
 */
public function toArray($notifiable)
{
    return [
        //
    ];
}
}

我在这里错过了什么吗?

4

1 回答 1

0

$this参考您的实际课程,您正在尝试使用getEmailForPasswordReset方法,CustomResetPassword但此方法不存在。

notification您可以像处理令牌一样将电子邮件传递给。

于 2016-12-14T10:10:47.560 回答