所以我有一个Laravel应用程序,但是我在sendEmailVerificationNotification
中覆盖了默认的App\User.php
函数。因为我不想要默认的电子邮件内容。
现在,当我注册时,我会收到一封电子邮件和激活信息……一切都很好。但是,当我单击链接时,出现500错误...因此,我去查看日志并看到以下错误:
Class 'App\Http\Controllers\Auth\Verified' not found
现在,确实不存在该类,因为我不知道在该类中应该做什么...
在我的User.php
中,verify
方法如下;
public function verify(Request $request): Response
{
if ($request->route('id') != $request->user()->getKey()) {
throw new AuthorizationException;
}
if ($request->user()->hasVerifiedEmail()) {
return redirect($this->redirectPath());
}
if ($request->user()->markEmailAsVerified()) {
event(new Verified($request->user()));
toastr()->success('Uw email is geverifiëerd', 'Gelukt!', ['timeOut' => 5000]);
}
return redirect($this->redirectPath())->with('verified', true);
}
完整的错误是这样的:
[2019-04-14 11:57:29]登台。错误:类 找不到'App \ Http \ Controllers \ Auth \ Verified' {“ userId”:3,“ exception”:“ [对象] (Symfony \ Component \ Debug \ Exception \ FatalThrowableError(代码:0): 在以下位置找不到类“ App \ Http \ Controllers \ Auth \ Verified” /var/www/rpr/releases/20190414113903/app/Http/Controllers/Auth/VerificationController.php:60)
VerficationController.php
中的第60行是带有}
的if语句的hasVerifiedEmail
。
有人可以解释一下我如何验证用户并发出帐户已验证的通知吗?
答案 0 :(得分:1)
您必须使用Auth
门面。将此行添加到您的控制器:
use Illuminate\Support\Facades\Auth;
答案 1 :(得分:0)
您忘记添加已验证的课程,然后添加:
use Illuminate\Auth\Events\Verified;