我有一些奇怪的问题。我不知道我做错了什么。
简单的邮件验证任务。如下:
在删除现有记录之前,一切正常。每次我尝试删除现有记录时,应用程序返回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
有帮助吗?提前致谢
试试这个:\ DB :: table('email_verifications') - > where('email',$ email) - > first() - > delete();