public function adduser()
    {
        $data = Auth::user()->ID;
        $GeneralData = Input::except(array('_token', 'status', 'pagename', 'profilepicture', 'profileimgedithidden', 'interest', 'update_profile', 'timezone'));
        $newimg = Input::file('profilepicture');
        if ($newimg != '') {
            $destinationPath = 'public/assets/upload/profile';
            $filename = Input::file('profilepicture')->getClientOriginalName();
            $Image = str_random(8) . '_' . $filename;
            $GeneralData['profilepicture'] = $Image;
            $uploadSuccess = Input::file('profilepicture')->move($destinationPath, $Image);
        }
        $interest = Input::get('interest');
        $interest_length = sizeof(Input::get('interest'));
        $GeneralData['status'] = 1;
        $cur_date = date('Y-m-d');
        $GeneralData['timezone'] = Input::get('timezone');
        $updaterules = array('username' => 'required|unique:user', 'password' => 'required|confirmed|min:5', 'email' => 'required|email|unique:user', 'dateofbirth' => 'required', 'timezone' => 'required|min:2');
        $validation = Validator::make($GeneralData, $updaterules);
        $newpassword = Input::get('password');
        if ($newpassword != "") {
            $GeneralData['password'] = Hash::make(Input::get('password'));
        } else {
            unset($GeneralData["password"]);
        }
        unset($GeneralData["password_confirmation"]);
        $updatedata = $GeneralData;
        $lantyp = Session::get('language');
        if ($lantyp == "") {
            $lantyp = "value_en";
        }
        if (!isset($updatedata['maritalstatus'])) {
            $updatedata['maritalstatus'] = 0;
        }
        if ($validation->passes()) {
            $affectedRows = ProfileModel::create($updatedata);
            $pass = $newpassword;
            $email = Input::get('email');
            $username = Input::get('username');
            Mail::send([], array('pass' => $pass, 'email' => $email, 'username' => $username), function ($message) use($pass, $email, $username) {
                $mail_body = '<style>.thank{text-align:center; width:100%;}
					.but_color{color:#ffffff;}
					.cont_name{width:100px;}
					.cont_value{width:500px;}
					
					</style>
				<body style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif; margin:0px auto; padding:0px;">

				<div style="margin:0px auto;background:#e5e5e5;float:left;	width:98%;	height:30px;margin:0px 1%;  border-bottom:#005377 1px solid;vertical-align: text-middle;">
					&nbsp;&nbsp;<a href="' . URL() . '"><img src="' . URL::to('assets/images/logo.png') . '" style="margin-top:3px; line-height:20px;" /></a>&nbsp;&nbsp;
				</div>
				<div style="background:#ffffff;float:left;padding:10px 20px;margin:1px 1%;" >
					<div class="thank" style="font-size:16px;color: #078AC2;font-weight:bold;float:left;width:100%;margin-top:10px;text-align:left;">Dear ' . $username . '</div>
					
					<div style="font-size:12px;	color: #000000;	float:left;padding:10px 2px;width:100%;margin:15px;">Your DingDatt Registration successfully completed.Your Login details are<br><br>Username: '******'<br>Password: '******'
				</div>
					
					<div style="margin:10px;"><a href="' . URL() . '"><img src="' . URL::to('assets/inner/images/vist_dingdatt.png') . '" width="120" height="30" /></a>
					</div>
				</div>
											
				<div style="font-size:12px; margin-top:10px;color: #5b5b5b;/*	background:#e5e5e5;*/width:95%;vertical-align: text-middle;height:30px;margin:0% 1%;padding:0px 15px; border-top:#005377 1px solid; border-bottom:5px solid background:#e5e5e5;line-height:25px; ">
				</body>';
                $message->setBody($mail_body, 'text/html');
                $message->to($email);
                $message->subject('DingDatt Registration');
            });
            $lantyp = Session::get('language');
            $labelname = ['txt_user_update_msg'];
            $languageDetails = languageModel::select($lantyp)->whereIn('ctrlCaptionId', $labelname)->get()->toArray();
            $user_id = Auth::user()->ID;
            $profileData = ProfileModel::where('ID', $user_id)->first();
            $interestList = InterestCategoryModel::lists('Interest_name', 'Interest_id');
            $userInterest = userinterestModel::where('user_id', $user_id)->lists('interest_id');
            $er_data['message'] = 'User details added successfully.';
            return Redirect::to('/user')->with('tab', 'userlist')->with('er_data', $er_data);
        } else {
            $languageDetails = languageModel::select($lantyp, 'ctrlCaptionId')->whereIn('value_en', [$validation->messages()->first('username'), $validation->messages()->first('password'), $validation->messages()->first('email'), $validation->messages()->first('dateofbirth'), $validation->messages()->first('timezone')])->get()->toArray();
            foreach ($languageDetails as $key => $val) {
                if (in_array($val['ctrlCaptionId'], ['alert_enterusername', 'alert_alreadyuser'])) {
                    $er_data['username'] = "******" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>";
                } elseif (in_array($val['ctrlCaptionId'], ['alert_enterpassword', 'alert_minpass5', 'alert_passconfnotmatch'])) {
                    $er_data['password'] = "******" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>";
                } elseif (in_array($val['ctrlCaptionId'], ['alert_enteremail', 'alert_validemail', 'alertr_emailalready'])) {
                    $er_data['email'] = "<span id='" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>";
                } elseif (in_array($val['ctrlCaptionId'], ['alert_enterdob'])) {
                    $er_data['dateofbirth'] = "<span id='" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>";
                } elseif (in_array($val['ctrlCaptionId'], ['txt_timezone_required'])) {
                    $er_data['timezone'] = "<span id='" . $val['ctrlCaptionId'] . "'>Timezone is required</span>";
                }
            }
            return Redirect::to('/user')->with('tab', 'createuser')->with('er_data', $er_data)->with('old_data', $updatedata);
        }
    }
 public function mobilegooglelogin()
 {
     $inpudetails = Input::except(array('link'));
     $inpudetails['google_id'] = Input::get('id');
     $emailid = Input::get('email');
     $curdate = date('Y-m-d h:i:s');
     $inpudetails['createddate'] = $curdate;
     //return $inpudetails;
     //$inpudetails['status']= 1;
     $validator = Validator::make($inpudetails, ProfileModel::$socialrules);
     if ($validator->passes()) {
         $verifyuser = ProfileModel::where('email', $emailid)->get()->count();
         $userid = ProfileModel::select('ID', 'status', 'firstname', 'lastname', 'username')->where('email', $emailid)->get();
         if ($verifyuser) {
             if ($userid[0]['status'] == 1) {
                 $userid1 = $userid[0]['ID'];
                 $updatedata['google_id'] = Input::get('id');
                 $updatedata['gcm_id'] = Input::get('gcm_id');
                 $updatedata['device_id'] = Input::get('device_id');
                 $updatedata['device_type'] = Input::get('device_type');
                 $userregister = ProfileModel::where('ID', $userid1)->update($updatedata);
                 if ($userid[0]['firstname'] != '') {
                     $name = $userid[0]['firstname'] . ' ' . $userid[0]['lastname'];
                 } else {
                     $name = $userid[0]['username'];
                 }
                 $Response = array('success' => '1', 'message' => 'successfully Login', 'userid' => $userid1, 'name' => $name, 'msgcode' => "c102");
                 $final = array("response" => $Response);
                 return json_encode($final);
             } else {
                 $admindetails = User::select('email')->where('ID', 1)->first();
                 $Response = array('success' => '0', 'message' => "Your account is inactive please contact admin (" . $admindetails->email . ")", 'mailid' => $admindetails->email, 'msgcode' => "c196");
                 $final = array("response" => $Response);
                 return json_encode($final);
             }
         } else {
             $inpudetails['google_id'] = Input::get('id');
             $inpudetails['status'] = '1';
             $inpudetails['gcm_id'] = Input::get('gcm_id');
             $inpudetails['device_id'] = Input::get('device_id');
             $inpudetails['device_type'] = Input::get('device_type');
             $inpudetails['timezone'] = Input::get('timezone');
             $saved = ProfileModel::create($inpudetails);
             if ($saved) {
                 $userid = ProfileModel::max('ID');
                 $Response = array('success' => '1', 'message' => 'successfully created Login', 'userid' => $userid, 'msgcode' => "c156");
                 $final = array("response" => $Response);
                 return json_encode($final);
             }
         }
     } else {
         $Response = array('success' => '0', 'message' => 'Some Fields are Missing', 'msgcode' => "c101");
         $final = array("response" => $Response);
         return json_encode($final);
     }
 }
    public function laravel_register()
    {
        $username = Input::get('username');
        $email = Input::get('email');
        $pass = Input::get('password');
        $password = Hash::make(Input::get('password'));
        $dateofbirth = Input::get('dateofbirth');
        $data = Input::except(array('_token', 'client_login'));
        // $validator = Validator::make($data,$rule);
        $validator = Validator::make($data, ProfileModel::$webrule);
        $lantyp = Session::get('language');
        $data['password'] = $password;
        if ($validator->fails()) {
            //return $validator->messages();
            if ($validator->messages()->first('terms') != "") {
                $terms = "Accept terms";
            } else {
                $terms = "";
            }
            $languageDetails = languageModel::select($lantyp, 'ctrlCaptionId')->whereIn('value_en', [$validator->messages()->first('username'), $validator->messages()->first('email'), $validator->messages()->first('password'), $validator->messages()->first('dateofbirth'), $terms])->get()->toArray();
            foreach ($languageDetails as $key => $val) {
                if (in_array($val['ctrlCaptionId'], ['alert_enterusername', 'alert_alreadyuser'])) {
                    $er_data['username'] = "******" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>";
                } elseif (in_array($val['ctrlCaptionId'], ['alert_enteremail', 'alert_validemail', 'alertr_emailalready'])) {
                    $er_data['email'] = "<span id='" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>";
                } elseif (in_array($val['ctrlCaptionId'], ['alert_enterpassword', 'alert_minpass5'])) {
                    $er_data['password'] = "******" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>";
                } elseif (in_array($val['ctrlCaptionId'], ['alert_enterdob'])) {
                    $er_data['dateofbirth'] = "<span id='" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>";
                } else {
                    if (in_array($val['ctrlCaptionId'], ['alert_enterterms'])) {
                        $er_data['terms'] = "<span id='" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>";
                    }
                }
            }
            //return $er_data;
            return View::make('user/register/userregister')->with('er_data', $er_data)->with('old_value', $data);
        } else {
            unset($data['terms']);
            $lantyp = Session::get('language');
            $data['timezone'] = "EST";
            $data['status'] = 1;
            $userregister = ProfileModel::create($data);
            Mail::send([], array('pass' => $pass, 'email' => $email, 'username' => $username), function ($message) use($pass, $email, $username) {
                //$user = MailTemplate::find(1);
                //$mail_body = $user->MailContent;
                //$mail_body = str_replace("{password}", Session::get('sess_string'), $mail_body);
                /* $mail_body = "Dear {username},<br><br>Your DingDatt Registration successfully completed.Your Login details are<br><br>Username: {username}<br>Password: {password} <br><br> Thank You, <br><br>Regards,<br>DingDatt";
                   $mail_body = str_replace("{password}", $pass, $mail_body);
                   $mail_body = str_replace("{username}", $username, $mail_body); */
                $mail_body = '<style>.thank{text-align:center; width:100%;}
					.but_color{color:#ffffff;}
					.cont_name{width:100px;}
					.cont_value{width:500px;}
					
					</style>
			 <body style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif; margin:0px auto; padding:0px;">

				<div style="margin:0px auto;background:#e5e5e5;float:left;	width:98%;	height:30px;margin:0px 1%;  border-bottom:#005377 1px solid;vertical-align: text-middle;">
					&nbsp;&nbsp;<a href="' . URL() . '"><img src="' . URL::to('assets/images/logo.png') . '" style="margin-top:3px; line-height:20px;" /></a>&nbsp;&nbsp;
				</div>
				<div style="background:#ffffff;float:left;padding:10px 20px;margin:1px 1%;" >
					<div class="thank" style="font-size:16px;color: #078AC2;font-weight:bold;float:left;width:100%;margin-top:10px;text-align:left;">Dear ' . $username . '</div>
					
					<div style="font-size:12px;	color: #000000;	float:left;padding:10px 2px;width:100%;margin:15px;">Your DingDatt Registration successfully completed.Your Login details are<br><br>Username: '******'<br>Password: '******'
			 </div>
					
					<div style="margin:10px;"><a href="' . URL() . '"><img src="' . URL::to('assets/inner/images/vist_dingdatt.png') . '" width="120" height="30" /></a>
					</div>
				</div>
											
				<div style="font-size:12px; margin-top:10px;color: #5b5b5b;/*	background:#e5e5e5;*/width:95%;vertical-align: text-middle;height:30px;margin:0% 1%;padding:0px 15px; border-top:#005377 1px solid; border-bottom:5px solid background:#e5e5e5;line-height:25px; ">
				
				</body>';
                $message->setBody($mail_body, 'text/html');
                $message->to($email);
                $message->subject('DingDatt Registration');
            });
            $labelname = ['txt_userdetaile_save_msg'];
            $languageDetails = languageModel::select($lantyp)->whereIn('ctrlCaptionId', $labelname)->get()->toArray();
            return View::make('user/register/userregister')->with('Message', $languageDetails[0][$lantyp]);
            //return Redirect::to('userregister')->with('Message', );
            // return Redirect::to('userregister')->with('Message', $languageDetails[0][$lantyp]);
        }
    }
 public function mobilegooglelogin()
 {
     $inpudetails = Input::except(array('link'));
     $inpudetails['google_id'] = Input::get('id');
     $emailid = Input::get('email');
     $curdate = date('Y-m-d h:i:s');
     $inpudetails['createddate'] = $curdate;
     //return $inpudetails;
     $validator = Validator::make($inpudetails, ProfileModel::$socialrules);
     if ($validator->passes()) {
         $verifyuser = ProfileModel::where('email', $emailid)->get()->count();
         $userid = ProfileModel::select('ID')->where('email', $emailid)->get();
         if ($verifyuser) {
             $userid1 = $userid[0]['ID'];
             $updatedata['google_id'] = Input::get('id');
             $updatedata['gcm_id'] = Input::get('gcm_id');
             $updatedata['device_id'] = Input::get('device_id');
             $updatedata['device_type'] = Input::get('device_type');
             $userregister = ProfileModel::where('ID', $userid1)->update($updatedata);
             $Response = array('success' => '1', 'message' => 'successfully Login', 'userid' => $userid1);
             $final = array("response" => $Response);
             return json_encode($final);
         } else {
             $inpudetails['google_id'] = Input::get('id');
             $inpudetails['status'] = 'A';
             $inpudetails['gcm_id'] = Input::get('gcm_id');
             $inpudetails['device_id'] = Input::get('device_id');
             $inpudetails['device_type'] = Input::get('device_type');
             $inpudetails['timezone'] = Input::get('timezone');
             $saved = ProfileModel::create($inpudetails);
             if ($saved) {
                 $userid = ProfileModel::max('ID');
                 $Response = array('success' => '1', 'message' => 'successfully created Login', 'userid' => $userid);
                 $final = array("response" => $Response);
                 return json_encode($final);
             }
         }
     } else {
         $Response = array('success' => '0', 'message' => 'Some Fields are Missing');
         $final = array("response" => $Response);
         return json_encode($final);
     }
 }