我有一些奇怪的问题。我不知道我做错了什么。
简单的电子邮件验证任务。如下:
在删除现有记录之前,一切正常。每次我尝试删除现有记录时,应用程序都会返回422 Unprocessable entity error。
控制器
public function verifyEmail(EmailVerifications $emailVerificationsRepo,
Request $request){
$this->emailVerificationValidator($request);
$status = $emailVerificationsRepo->verify(
$request->get('email'),
$request->get('token')
);
if($status){
return $this->successResponse();
}
return $this->errorResponse();
}
存储库
/**
* Verify activation code
* @param string $email
* @param string $token
* @return boolean
*/
public function verify($email, $token){
$verification = $this->findWhere([
'email' => $email,
])->first();
if(!$verification){
return false;
}
if(app('hash')->check($token, $verification->verification_code)){
$user = $verification->user;
\DB::table('email_verifications')->where('email', $email)->delete();
$user->verifyEmail();
return true;
}
return false;
}
/**
* Delete all verification records for giving email
* @param string $email
* @return boolean
*/
protected function deleteExisting($email){
return $this->deleteWhere([
'email' => $email,
]);
}
环境:
MacOs,Nginx,Lumen 5.5
有任何帮助吗?提前谢谢
答案 0 :(得分:-1)
试试这个: \ DB :: table('email_verifications') - > where('email',$ email) - > first() - > delete();