【发布时间】:2019-12-05 11:54:30
【问题描述】:
我将通知类设为MailResetPasswordNotification,并使用以下内容编辑了通知的邮件表示。
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!');
}
我还在vendor/laravel/framework/src/illuminate/Auth/Passwords/CanResetPassword.php中找到了重置密码的文件,并用我的方法覆盖了它:
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));
}
}
但是,我收到以下错误。
找不到类“Illuminate\Auth\Passwords\App\Notifications\MailResetPasswordNotification”
【问题讨论】:
-
你的文件
CanResetPassword.php在哪里? -
你NOT编辑
vendor中的文件......只需覆盖模型上的方法,你必须正确引用类(命名空间) -
如何覆盖仅位于供应商中的方法?在任何地方都找不到?@lagbox
-
你试过
composer dump吗? -
您在模型上定义覆盖特征版本的方法
标签: php laravel laravel-5 laravel-6 illuminate-container