Laravel 5.8 Class'App Http Controllers Auth Verified'未找到

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Laravel 5.8 Class'App Http Controllers Auth Verified'未找到相关的知识,希望对你有一定的参考价值。

所以我有一个Laravel应用程序,但我已经覆盖了我的sendEmailVerificationNotification中的默认AppUser.php函数。因为我不想要默认的电子邮件。

现在,当我注册时,我收到一封电子邮件和激活等......这一切都很完美。但是,当我单击链接时,我收到500错误...所以我去查看日志并查看以下错误:

Class 'AppHttpControllersAuthVerified' 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] staging.ERROR:Class'App Http Controllers Auth Verified'not found {“userId”:3,“exception”:“[object](Symfony Component Debug Exception FatalThrowableError(代码:0):在/var/www/rpr/releases/20190414113903/app/Http/Controllers/Auth/VerificationController.php:60找不到类'App Http Controllers Auth Verified' )

VerficationController.php的60号线是}的if语句的hasVerifiedEmail

有人可以解释我如何只是验证用户并发出帐户已经过验证的通知吗?

答案

你必须使用Auth门面。将此行添加到您的控制器:

use IlluminateSupportFacadesAuth;
另一答案

您忘记将Verified类添加到您的使用中,然后添加:

use IlluminateAuthEventsVerified;

以上是关于Laravel 5.8 Class'App Http Controllers Auth Verified'未找到的主要内容,如果未能解决你的问题,请参考以下文章