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); }
public function getcommentsdetails() { $userid = Input::get('userid'); $contest_participant_id = Input::get('contest_participant_id'); /// Verifying the followers $contestdetailscount = contestparticipantModel::where('ID', $contest_participant_id)->get()->count(); $contestdetails = contestparticipantModel::where('ID', $contest_participant_id)->get()->toArray(); $contestparticipantid = $contestdetails[0]['user_id']; $followers = followModel::where('userid', $userid)->where('followerid', $contestparticipantid)->get()->count(); //// Get Comments $getcommentscount = commentModel::where('contest_participant_id', $contest_participant_id)->get()->count(); if ($getcommentscount) { $getcomments = commentModel::select('comments.id as comment_id', 'comments.contest_participant_id', 'comments.comment', 'user.ID as userid', 'user.firstname', 'user.lastname', 'user.username', 'user.profilepicture')->where('comments.contest_participant_id', $contest_participant_id)->LeftJoin('user', 'user.ID', '=', 'comments.userid')->get(); for ($i = 0; $i < count($getcomments); $i++) { if ($getcomments[$i]['firstname'] != '') { $getcomments[$i]['name'] = $getcomments[$i]['firstname'] . ' ' . $getcomments[$i]['lastname']; } else { $getcomments[$i]['name'] = $getcomments[$i]['username']; } if ($getcomments[$i]['profilepicture'] != '') { $getcomments[$i]['profilepicture'] = url() . '/public/assets/upload/profile/' . $getcomments[$i]['profilepicture']; } } /*DB::select("SELECT user.*,DATE_FORMAT(CONVERT_TZ(`dateofbirth`,'+00:00','$timezone'),'%Y-%m-%d') as converteddateofbirth FROM user WHERE ID =$userid"); $getcomments = commentModel::select('comments.id as comment_id','comments.contest_participant_id','comments.comment','user.ID as userid','user.firstname','user.profilepicture' ) ->where('comments.contest_participant_id',$contest_participant_id) ->LeftJoin('user','user.ID','=','comments.userid')->get(); */ $Response = array('success' => '1', 'message' => 'Getting Comments details', 'msgcode' => "c132"); $final = array("response" => $Response, "Comments" => $getcomments, "followers" => $followers); return json_encode($final); } else { $Response = array('success' => '0', 'message' => 'No Comments Available in this Contest participant', 'msgcode' => "c133"); $final = array("response" => $Response, "followers" => $followers); return json_encode($final); } /*return replycommentModel::select('replycomment.id', 'comments.id as comment_id','comments.contest_participant_id','replycomment.replycomment','comments.comment' ) ->RIGHTJOIN('comments','comments.id','=','replycomment.comment_id') ->where('comments.contest_participant_id',$contest_participant_id)->get(); */ }