I am to append the users email address in the URL when doing password reset, so the reset url would look like this http://blog.dev/password/reset/4cfbb048346474aab7080c88f16c34b9ea377b9ea35804387216fce303a38855?email=test%40gmail.com
However I get the error FatalErrorException in CustomResetPassword.php line 54: Call to undefined method App\Notifications\CustomResetPassword::getEmailForPasswordReset()
I am sending the reset email through a custom notification class the code is as follows
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 [
//
];
}
}
Am I missing something here?
$this
refer to your actual class, you're trying to usegetEmailForPasswordReset
method ofCustomResetPassword
but this method doesn't exist.You can pass the email to the
notification
as you did for the token.