public function recover(Request $request){
$email = $request->input('email');
// Create tokens
$selector = bin2hex(random_bytes(8));
$token = random_bytes(32);
$url = sprintf('%s', route('recover.reset',['selector'=>$selector, 'validator'=>bin2hex($token)]));
// Token expiration
$expires = new DateTime('NOW');
$expires->add(new DateInterval('PT01H')); // 1 hour
// Delete any existing tokens for this user
DB::delete('delete * from password_reset where email =?', $email);
// Insert reset token into database
$insert = $this->db->insert('password_reset',
array(
'email' => $email,
'selector' => $selector,
'token' => hash('sha256', $token),
'expires' => $expires->format('U'),
)
);
我正在尝试实现忘记密码功能,当提交电子邮件表单到forgotPasswordController时,会生成以下错误:
"Class 'App\Http\Controllers\DateTime' not found"
这是控制器的图片,上面的代码不在那里,我无法修改它: RecoverPasswordController Image
在头部我已经尝试使用
use DateTime;
或者
use App\Http\Controllers\DateTime
但仍会产生相同的错误,请帮忙修复。提前致谢。
new \DateTime()
或Laravel的Carbon
类。 - brombeeruse DateTime;
时,错误仍然是 Class 'App\Http\Controllers\DateTime' not found 吗? - Rafaeluse DateTime;
成功解决了问题,但是我在不同的目录中有两个重复的 ForgotPasswordController,所以我必须找到它指向的控制器。谢谢大家。 - myckhel