Laravel 5.2电子邮件验证错误
我继续学习教程,帮助我为新用户建立电子邮件验证。 我不断得到错误:Laravel 5.2电子邮件验证错误,laravel,email,verification,Laravel,Email,Verification,我继续学习教程,帮助我为新用户建立电子邮件验证。 我不断得到错误: FatalErrorException in ActivationService.php line 66: Call to a member function getActivation() on null 下面是routes.php: Route::auth(); Route::get('user/activation/{token}', 'Auth\AuthController@activateUser')->nam
FatalErrorException in ActivationService.php line 66:
Call to a member function getActivation() on null
下面是routes.php:
Route::auth();
Route::get('user/activation/{token}', 'Auth\AuthController@activateUser')->name('user.activate');
Route::get('/', 'HomeController@index');
Route::get('auth/logout', 'Auth\AuthController@getLogout');
Route::get('/home', 'HomeController@index');
这是.env文件
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_FROM=*from address given by mailgun*
MAIL_NAME=CompanyName
MAIL_PORT=587
MAIL_USERNAME=*Mailgun username*
MAIL_PASSWORD=*Mailgun password*
MAIL_ENCRYPTION=tls
MAILGUN_DOMAIN=*mailgun domain*
MAILGUN_SECRET=*secret key*
其他一切都已根据教程中给出的代码完成。请参考代码,因为我的代码与类的代码相同 尝试添加使用App\ActivationRepository在下的ActivationService中使用light\Mail\Message强>
问题似乎是$this->activationRepo为null,而不是ActivationRepository的实例 这是什么时候发生的?当新用户注册或未激活的用户尝试登录时?当新用户注册时。尽管抛出了错误,它仍然会进入SQL数据库。在ActivationService类构造函数中,您是否如教程所述初始化activationRepo?问题是shouldSend()函数中的$this->acticationRepo为null。这就是应该解决的问题。是的,这样做完全是逐字逐句的。ActivationRepository和ActivationService类都在同一个命名空间下。不需要添加“使用…”。我同意这里的@Makan