new OTP send or resend OTP after 60 seond in php laravel

if (User::where('phone', $input['phone'])->exists()) {
  $success['result']=User::where('phone', $input['phone'])->whereRaw("updated_at >=('" . date('Y-m-d H:i:s') . "'-INTERVAL 60 SECOND) AND updated_at <='" . date('Y-m-d H:i:s') . "'")->exists();
  if(!$success['result']){
    $success['otp']=$otp; 
  $affectedRows = User::where('phone', $input['phone'])->update(array('otp' => $otp,'password'=>Hash::make($otp)));
  }else { $isSend = 0; }
}else{
  $success['result']=false;
  $success['otp']=$otp;
  $input['password'] = Hash::make($otp);
  $input['otp']=$otp;
  $user = User::create($input);
}
if($isSend)
{
$otp_response=json_decode($this->sendOtp($data,$otp));
$success['otp_response']=$otp_response->status;
//$otp_response->status == "success"
}


Leave a Reply