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

问题描述 投票:-1回答:2

所以我有一个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] 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

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

php laravel laravel-5 email-verification
2个回答
1
投票

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

use Illuminate\Support\Facades\Auth;

0
投票

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

use Illuminate\Auth\Events\Verified;
© www.soinside.com 2019 - 2024. All rights reserved.