无法删除模型,如果应用程序返回错误

I have some weird issue. I don't know if I'm doing anything wrong.

Task

Simple email verification task. As below:

  1. User submit request to get new email verification link to his inbox.
  2. User click on the link was sent to his inbox which lead to verification page
  3. The application verify email and verification token passed in URL
  4. If email and token verified. Application will mark user as verified user and delete existing verification code recored/model from email verifications table.

Everything is working fine until deleting the existing record. Each time I try to delete the existing record the application returns 422 Unprocessable entity error.

Code

Controller

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();
  }

Repository

/**
   * 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,
  ]);
}

Environment:

MacOs, Nginx, Lumen 5.5

Any help? thanks in advance

try this: \DB::table('email_verifications')->where('email', $email)->first()->delete();