phplaravellaravel-5laravel-6illuminate-container

Lavarel Illuminate class for mail reset not found


I made a notification class as MailResetPasswordNotification and edited the mail representation of the notification with the following.

public function toMail($notifiable)
{
    $link = url("/password/reset/?token=".$this->token);

    return (new MailMessage)
        ->view('reset.emailer')
        ->from('info@example.com')
        ->subject('Reset your password')
        ->line("Hey, We've successfully changed the text ")
        ->action('Reset Password', $link)
        ->attach('reset.attachment')
        ->line('Thank you!');
}

I also found the file for resetting password in vendor/laravel/framework/src/illuminate/Auth/Passwords/CanResetPassword.php and overrode it with mine like:

namespace Illuminate\Auth\Passwords;

use Illuminate\Auth\Notifications\ResetPassword as MailResetPasswordNotification;

trait CanResetPassword
{
    public function getEmailForPasswordReset()
    {
        return $this->email;
    }

    public function sendPasswordResetNotification($token)
    {
        $this->notify(new App\Notifications\MailResetPasswordNotification($token));
    }
}

However, I get the following error.

Class 'Illuminate\Auth\Passwords\App\Notifications\MailResetPasswordNotification' not found


Solution

  • You need to create a method sendPasswordResetNotification in a class that implements CanResetPassword