Exemplo n.º 1
0
 public function Verification()
 {
     $mailaddress = Input::get('email');
     if (Input::has('code')) {
         $mailcode = Input::has('code');
     } else {
         return "code field is blanck";
     }
     $user_email = $mailaddress . "*manual";
     //----------------------------------------------------------------------------code edit
     $getdatabasecode = UserRegistrationModel::where('user_email', '=', $user_email)->pluck('user_code');
     if ($getdatabasecode) {
         $registration_result = array();
         if ($getdatabasecode == $mailcode) {
             $sql_update = UserRegistrationModel::where('user_email', '=', $user_email)->update(['user_validation_status' => 1]);
             if ($sql_update) {
                 $tempdata = UserRegistrationModel::where('user_email', '=', $user_email)->first();
                 //"SELECT user_name,user_email,user_phone,user_pass,user_type FROM tbl_user_registration WHERE user_email='$mailaddress'";
                 //$insert_queary = "INSERT INTO tbl_user_info (user_name,user_email,user_phone,user_pass,user_type) VALUES ('$getdata[0]','$getdata[1]','$getdata[2]','$getdata[3]','$getdata[4]');";
                 $maininsert = new UserLoginModel();
                 $maininsert->user_name = $tempdata->user_name;
                 $maininsert->user_email = $tempdata->user_email;
                 $maininsert->user_phone = $tempdata->user_phone;
                 $maininsert->password = $tempdata->password;
                 $maininsert->user_type = $tempdata->user_type;
                 if ($maininsert->save()) {
                     $sql_delete = UserRegistrationModel::where('user_email', '=', $user_email)->delete();
                     if ($sql_delete) {
                         $sqldata = UserLoginModel::where('user_email', '=', $user_email)->first();
                         $this->update_status($user_email);
                         $registration_result['VerificationResult'] = ['Status' => 'Success', 'data' => ['id' => $sqldata->id, 'user_name' => $sqldata->user_name, 'user_email' => $sqldata->user_email, 'user_phone' => $sqldata->user_phone, 'user_type' => $sqldata->user_type]];
                         return json_encode($registration_result);
                     } else {
                         $registration_result['VerificationResult'] = ['Status' => 'Fail', 'data' => ""];
                         return json_encode($registration_result);
                     }
                 } else {
                     return "";
                 }
             } else {
                 return "";
             }
         } else {
             $registration_result['VerificationResult'] = ['Status' => 'Fail', 'data' => 'Verification Code Does Not Match'];
             return json_encode($registration_result);
         }
     } else {
         return "email address not registered";
     }
 }
 public function RegistrationProcess()
 {
     $user_name = Input::get('user_name');
     $user_mail = Input::get('email');
     $user_phone = Input::get('mobile_no');
     $user_password = Input::get('password');
     $user_type = Input::get('reg_type');
     $user_email = $user_mail . "*" . $user_type;
     $maintablecheckreg = UserLoginModel::where('user_email', '=', $user_email)->exists();
     $temptablecheck = UserRegistrationModel::where('user_email', '=', $user_email)->where('user_validation_status', '=', 0)->pluck('id');
     if ($maintablecheckreg || $temptablecheck > 0) {
         if ($maintablecheckreg) {
             if (strcasecmp($user_type, "facebook") == 0 || strcasecmp($user_type, "google_plus") == 0 || strcasecmp($user_type, "twitter") == 0) {
                 $this->update_status($user_email);
                 $sql = UserLoginModel::where('user_email', '=', $user_email)->first();
                 return json_encode($sql);
             } else {
                 return "already registered manual user";
             }
         } else {
             return "user not verified";
         }
     } else {
         if (strcasecmp($user_type, "manual") == 0) {
             $generated_code = rand(50, 1000);
             $starttime = new \DateTime();
             $start_time = $starttime->format('Y-m-d H:i:s');
             $endtime = new \DateTime('+1 days');
             $end_time = $endtime->format('Y-m-d H:i:s');
             $user_validation_status = 0;
             $user_active_status = 0;
             $insert = new UserRegistrationModel();
             $insert->user_name = $user_name;
             $insert->user_email = $user_email;
             $insert->user_phone = $user_phone;
             $insert->password = $user_password;
             $insert->user_type = $user_type;
             $insert->start_time = $start_time;
             $insert->end_time = $end_time;
             $insert->user_validation_status = $user_validation_status;
             $insert->user_active_status = $user_active_status;
             $insert->user_code = $generated_code;
             try {
                 $insert->save();
                 if ($this->MailTransfer($user_mail, $user_name, $generated_code)) {
                     return "request for verify";
                 }
             } catch (\Illuminate\Database\QueryException $e) {
                 return $e->getMessage();
             }
         } elseif (strcasecmp($user_type, "facebook") == 0 || strcasecmp($user_type, "google_plus") == 0 || strcasecmp($user_type, "twitter") == 0) {
             $sinsert = new UserLoginModel();
             $sinsert->user_name = $user_name;
             $sinsert->user_email = $user_email;
             $sinsert->user_phone = $user_phone;
             $sinsert->password = $user_password;
             //Hash::make($user_password);
             $sinsert->user_type = $user_type;
             if ($sinsert->save()) {
                 $this->update_status($user_email);
                 $sql = UserLoginModel::where('user_email', '=', $user_email)->first();
                 return json_encode($sql);
             } else {
                 return "fail registration complete via" . $user_type;
             }
         }
         return "";
     }
 }