Laravel 5.3报错:`Creating default object from empty value`
程序员文章站
2022-04-26 10:17:07
...
这是代码:
ActivationService.php
mailer = $mailer;
$this->activationRepo = $activationRepo;
}
public function sendActivationMail($user)
{
if ($user->activated || !$this->shouldSend($user)) {
return;
}
$token = $this->activationRepo->createActivation($user);
$link = route('user.activate', $token);
$message = sprintf('Activate account %s', $link, $link);
$this->mailer->raw($message, function (Message $m) use ($user) {
$m->to($user->email)->subject('Activation mail');
});
}
public function activateUser($token)
{
$activation = $this->activationRepo->getActivationByToken($token);
if ($activation === null) {
return null;
}
$user = User::find($activation->user_id);
//下面这行是53行.
$user->activated = true;
$user->save();
$this->activationRepo->deleteActivation($token);
return $user;
}
private function shouldSend($user)
{
$activation = $this->activationRepo->getActivation($user);
return $activation === null || strtotime($activation->created_at) + 60 * 60 * $this->resendAfter
错误信息:
ErrorException in ActivationService.php line 53:
Creating default object from empty value
53行的位置在代码中有注释,代码是$user->activated = true;
问题:
上面的代码如何解决这个错误?
推荐阅读
-
php警告Creating default object from empty value 问题的解决方法
-
php警告Creating default object from empty value 问题的解决方法_PHP教程
-
php警告Creating default object from empty value 问题的解决方法_php技巧
-
Laravel 5.3报错:`Creating default object from empty value`
-
php警告Creating default object from empty value 问题的解决方法_PHP教程
-
php开发遇到错误 Creating default object from empty value 求大神帮忙解决下
-
php开发遇到错误 Creating default object from empty value 求大神帮忙解决下
-
Laravel 5.3报错:`Creating default object from empty value`
-
php警告Creating default object from empty value 问题的解决方法
-
thinkphp5.1报错 Creating default object from empty value