public function submitforhelp() { if (!empty(Input::get('question_id'))) { $question_id = Input::get('question_id'); } $giver_id = Auth::user()->id; if (!empty($question_id) && !empty($giver_id)) { $Questionwillingtohelp = new Questionwillingtohelp(); $Questionwillingtohelp->question_id = $question_id; $Questionwillingtohelp->user_id = $giver_id; if ($Questionwillingtohelp->save()) { $helper = User::find($giver_id); $helper->karmascore = $helper->karmascore + 2; if ($helper->save()) { return Redirect::to('/karma-queries'); } } } }
public static function otherProfileTrail() { $karmacircleFeed = Karmafeed::select('message_type As type', 'id_type', 'receiver_id', 'giver_id', 'updated_at')->get(); foreach ($karmacircleFeed as $karmaFeed) { $receiverId = $karmaFeed->receiver_id; $giverId = $karmaFeed->giver_id; $karmaFeedMessage = $karmaFeed->type; $karmaFeedId = $karmaFeed->id_type; $karmaFeedDate = $karmaFeed->updated_at; if (!empty($receiverId)) { $receiverData = User::where('id', '=', $receiverId)->select('fname As receiverFirstName', 'lname As receiverLastName', 'piclink As receiverPic')->first(); } if (!empty($giverId)) { $giverData = User::where('id', '=', $giverId)->select('fname As giverFirstName', 'lname As giverLastName', 'piclink As giverPic')->first(); } if ($karmaFeedMessage == 'KarmaNote') { $getKarmaNoteDetails = Karmanote::where('id', '=', $karmaFeedId)->select(array('karmanotes.details As description'))->first(); $karmaNoteFeed[] = array_merge($karmaFeed->toArray(), $getKarmaNoteDetails->toArray(), $giverData->toArray(), $receiverData->toArray()); } else { $karmacircleFeedCount = DB::table('users_karmafeeds')->where('message_type', '=', 'KarmaNote')->count(); if ($karmacircleFeedCount < 1) { $karmaNoteFeed = array(); } } if ($karmaFeedMessage == 'Group') { $getGroupDetails = Group::where('id', '=', $karmaFeedId)->select(array('groups.name As name', 'groups.description As description'))->first(); $groupFeed[] = array_merge($karmaFeed->toArray(), $getGroupDetails->toArray(), $receiverData->toArray()); } else { $karmacircleGroupCount = DB::table('users_karmafeeds')->where('message_type', '=', 'Group')->count(); if ($karmacircleGroupCount < 1) { $groupFeed = array(); } } if ($karmaFeedMessage == 'KarmaQuery') { $getQueryDetails = Question::where('id', '=', $karmaFeedId)->select(array('questions.queryStatus As queryStatus', 'questions.description As description'))->first(); $queryFeed[] = array_merge($karmaFeed->toArray(), $getQueryDetails->toArray(), $receiverData->toArray()); } else { $karmacircleQueryCount = DB::table('users_karmafeeds')->where('message_type', '=', 'Question')->count(); if ($karmacircleQueryCount < 1) { $queryFeed = array(); } } if ($karmaFeedMessage == 'OfferHelpTo') { $getOfferHelpDetails = Question::where('id', '=', $karmaFeedId)->select(array('questions.queryStatus As queryStatus', 'questions.description As description'))->first(); $getOfferHelpCount = Questionwillingtohelp::has('id')->where('user_id', '=', $receiverId)->where('question_id', '=', $karmaFeedId)->count(); $offerHelpToFeed[] = array_merge($karmaFeed->toArray(), $getOfferHelpDetails->toArray(), $receiverData->toArray(), $giverData->toArray()); } else { $offerHelpToFeedCount = DB::table('users_karmafeeds')->where('message_type', '=', 'OfferHelpTo')->count(); if ($offerHelpToFeedCount < 1) { $offerHelpToFeed = array(); } } } $feed = array_merge($karmaNoteFeed, $groupFeed, $queryFeed); $sort = array(); foreach ($feed as $k => $v) { $sort['updated_at'][$k] = $v['updated_at']; } array_multisort($sort['updated_at'], SORT_DESC, $feed); echo "<pre>"; print_r($arr); die; echo '<pre>'; print_r($feed); die; }
public function deletequery() { $id = Input::get('queryId'); $deleteQuestionwillingtohelp = Questionwillingtohelp::where('question_id', '=', $id)->delete(); $deleteGroupQuestion = Groupquestion::where('question_id', '=', $id)->delete(); $deleteQuestion = Question::where('id', '=', $id)->delete(); $deleteKarmafeed = Karmafeed::where('id_type', '=', $id)->whereIn('message_type', array('KarmaQuery', 'OfferHelpTo'))->delete(); $deleteMykarma = Mykarma::where('entry_id', '=', $id)->whereIn('users_role', array('PostedQuery', 'OfferedHelp'))->delete(); echo "Question " . $id . " deleted"; }