我尝试在用户在我的网络应用中完成注册后发送验证链接。我已成功向用户发送了一封电子邮件,但当我点击电子邮件中的链接时出现此错误
Class 'App\Http\Controllers\InvalidConfirmationCodeException' not found
这是我的控制器
public function confirm($code)
{
if( ! $code)
{
throw new InvalidConfirmationCodeException;
}
$user = User::whereConfirmationCode($code)->first();
if (!$user)
{
throw new InvalidConfirmationCodeException;
}
$user->confirmed = 1;
$user->confirmation_code = null;
$user->save();
Flash::message('You have successfully verified your account.');
return Redirect::to('/login');
}
可能的错误是什么?请帮忙
答案 0 :(得分:2)
您的 InvalidConfirmationCodeException 可能位于 App \ Http \ Controllers 之外的其他命名空间中,这就是无法找到它的原因。使用命名空间的类名
throw new \Your\Exceptions\Namespace\InvalidConfirmationCodeException;
或使用控制器文件顶部的使用语句导入例外类:
<?php namespace App\Http\Controllers;
use Your\Exceptions\Namespace\InvalidConfirmationCodeException;