public function deletecategory() { $categoryid = Input::get('categoryid'); $usercategory = userinterestModel::where('interest_id', $categoryid)->get()->count(); $contestcategory = contestinterestModel::where('category_id', $categoryid)->get()->count(); if ($usercategory > 0 || $contestcategory > 0) { $er_data = 'This category is used. So not able to delete '; return Redirect::to('category')->with('er_data', $er_data); } else { $deletecategory = InterestCategoryModel::where('Interest_id', $categoryid)->delete(); if ($deletecategory) { $er_data = 'Category deleted successfully'; return Redirect::to('category')->with('er_data', $er_data); } } }
public function profileupdate($data = Null) { //$data = Auth::user()->ID; $editid = $data; $GeneralData = Input::except(array('_token', 'status', 'pagename', 'profilepicture', 'profileimgedithidden', 'interest', 'update_profile')); $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')); if ($interest_length > 0) { userinterestModel::whereNotIn('interest_id', $interest)->where('user_id', '=', $data)->delete(); for ($i = 0; $i < $interest_length; $i++) { $interes['user_id'] = $data; $interes['interest_id'] = $interest[$i]; $userInterest = userinterestModel::where('user_id', $data)->where('interest_id', $interest[$i])->lists('interest_id'); if (count($userInterest) < 1) { userinterestModel::create($interes); } unset($interes); } } else { userinterestModel::where('user_id', '=', $data)->delete(); } $cur_date = date('Y-m-d'); $updaterules = array('username' => 'required|unique:user,username,' . $data, 'password' => 'confirmed|min:5', 'email' => 'required|email|unique:user,email,' . $data, '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::where('ID', $data)->update($updatedata); $lantyp = Session::get('language'); $labelname = ['txt_user_update_msg']; $languageDetails = languageModel::select($lantyp)->whereIn('ctrlCaptionId', $labelname)->get()->toArray(); $user_id = $data; $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'] = "<span id='txt_user_update_msg'>" . $languageDetails[0][$lantyp] . "</span>"; return Redirect::to('/edit_profile/' . $data)->with('er_data', $er_data)->with('user_id', $user_id); } 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('/edit_profile/' . $data)->with('er_data', $er_data)->with('old_data', $updatedata); } }
public function userdelete() { $userid = $_GET['userid']; /// Comment delete ////////// $cmtcnt = commentModel::select('id')->where('userid', $userid)->get(); for ($i = 0; $i < count($cmtcnt); $i++) { $replycnt = replycommentModel::where('comment_id', $cmtcnt[$i]['id'])->get()->count(); if ($replycnt) { replycommentModel::where('comment_id', $cmtcnt[$i]['id'])->delete(); } } /// REply comt delete ///// $replycmtcnt = replycommentModel::where('user_id', $userid)->get()->count(); if ($replycmtcnt) { replycommentModel::where('user_id', $userid)->delete(); } /// Contest delete///// $contestcnt = contestModel::select('ID')->where('createdby', $userid)->get(); for ($k = 0; $k < count($contestcnt); $k++) { $conpartdet = contestparticipantModel::select('ID')->where('contest_id', $contestcnt[$k]['ID'])->get(); for ($p = 0; $p < count($conpartdet); $p++) { $cmtcnt = commentModel::where('contest_participant_id', $conpartdet[$p]['ID'])->delete(); votingModel::where('contest_participant_id', $conpartdet[$p]['ID'])->delete(); } $contestintrdlet = contestinterestModel::where('contest_id', $contestcnt[$k]['ID'])->delete(); invitefollowerforcontestModel::where('contest_id', $contestcnt[$k]['ID'])->delete(); invitegroupforcontestModel::where('contest_id', $contestcnt[$k]['ID'])->delete(); leaderboardModel::where('contest_id', $contestcnt[$k]['ID'])->delete(); privateusercontestModel::where('contest_id', $contestcnt[$k]['ID'])->delete(); contestModel::where('createdby', $userid)->delete(); contestparticipantModel::where('contest_id', $contestcnt[$k]['ID'])->delete(); } ///Contestparticipant delete /////////// $contestparticipant = contestparticipantModel::where('user_id', $userid)->get(); for ($p = 0; $p < count($contestparticipant); $p++) { $cmtcnt = commentModel::where('contest_participant_id', $contestparticipant[$p]['ID'])->delete(); votingModel::where('contest_participant_id', $contestparticipant[$p]['ID'])->delete(); } ///////////////Group ////////////////// $group = groupModel::select('ID')->where('createdby', $userid)->get(); if (count($group) > 0) { groupmemberModel::where('group_id', $group[0]['ID'])->delete(); invitegroupforcontestModel::where('group_id', $group[0]['ID'])->delete(); invitememberforgroupModel::where('group_id', $group[0]['ID'])->delete(); } contestparticipantModel::where('user_id', $userid)->delete(); followModel::where('userid', $userid)->delete(); followModel::where('followerid', $userid)->delete(); userinterestModel::where('user_id', $userid)->delete(); votingModel::where('user_id', $userid)->delete(); invitememberforgroupModel::where('user_id', $userid)->delete(); groupmemberModel::where('user_id', $userid)->delete(); ProfileModel::where('ID', $userid)->delete(); $er_data['message'] = 'User details deleted successfully'; return Redirect::to('user')->with('er_data', $er_data); }
?> <div class="main_head" style="width:180px;"><span id="txt_editmyprofile" class="txt_editmyprofile">Edit Profile</span></div> <div class="main_wrap" style="background-colour:"> <form id="editprofile" name="edit_profile_update" enctype="multipart/form-data" action="<?php echo url() . "/edit_profile_update/" . $user_id; ?> " method="post" class="form_mid"> @if(isset($er_data['Message'])) <p class="alert" style="color:green;padding:5px;text-align:center;font-size:13px">{{ $er_data['Message'] }}</p> @endif <?php //$user_id = Auth::user()->ID; $user_id = $user_id; $profileData = ProfileModel::where('ID', $user_id)->first(); $interestList = InterestCategoryModel::where('status', 1)->lists('Interest_name', 'Interest_id'); $userInterest = userinterestModel::where('user_id', $user_id)->lists('interest_id'); $timezoneList = timezoneDBModel::lists('timezonename', 'timezonevalue'); ?> <div class="loginform loginbox mar1"> <legend class="radius"><div class="leg_head"><span id="txt_logininfo">Login Info</span></div> <p> <div class="inp_pfix"><img src="{{ URL::to($assets_path.'img/user_icons.png') }}" width="25" height="25"></div> <input type="text" id="pch_username" name="username" placeholder="User Name" title="User Name" value="{{ isset($old_data['username'])?$old_data['username']:$profileData['username'] }}" <?php if (Auth::user()->ID != $user_id) { echo "readonly"; } ?> class="radius pfix_mar" /> </p> @if(isset($er_data['username'])) <p class="alert" style="text-align:left;margin-left:55px;color:red;">{{ $er_data['username'] }}</p>
public function editmyprofile() { $GeneralData = array_filter(Input::except(array('_token', 'passwordhidden', 'profilepicture', 'interest_id', 'userid', 'timezone', 'dateofbirth'))); $timezone = Input::get('timezone'); $GeneralData['dateofbirth'] = timezoneModel::convert(Input::get('dateofbirth'), $timezone, 'UTC', 'Y-m-d'); $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); } else { //$GeneralData['profilepicture']=Input::get('profileimgedithidden'); } $GeneralData['status'] = 1; $data = Input::get('userid'); $newpassword = Input::get('password'); $updaterules = array('username' => 'required|unique:user,username,' . $data, 'password' => 'confirmed:min:5', 'email' => 'required|email|unique:user,email,' . $data); $validation = Validator::make($GeneralData, $updaterules); if ($validation->passes()) { if ($newpassword != "") { $GeneralData['password'] = Hash::make(Input::get('password')); } unset($GeneralData["password_confirmation"]); $affectedRows = ProfileModel::where('ID', $data)->update($GeneralData); $interest_id = Input::get('interest_id'); $interestid = explode(',', $interest_id); $interestidcount = count($interestid); $interest['user_id'] = Input::get('userid'); $affectedRows = userinterestModel::where('user_id', $data)->delete(); for ($i = 0; $i < $interestidcount; $i++) { $interest['interest_id'] = $interestid[$i]; $validationinterest = Validator::make($interest, userinterestModel::$rules); if ($validationinterest->passes()) { $userregister = userinterestModel::create($interest); } } $Response = array('success' => '1', 'message' => 'Record Updated successfully', 'msgcode' => "c109"); $final = array("response" => $Response); return json_encode($final); } else { $Response = array('success' => '0', 'message' => $validation->messages()->first(), 'msgcode' => "c110"); $final = array("response" => $Response); return json_encode($final); } }