public function fetchPostByID() { $user = Auth::user(); $input = Input::all(); // search for post by ID //$searchForPost = DB::table('posts')->where('id', $input['postid'])->get(); $post = Post::where('id', $input['postid'])->take(1)->get(); //$jsonOut = json_decode($searchForPost[0]->status); $post->status = $post[0]->filterStatus(); $post->image = ($post[0]->statustype = 'image') ? $post[0]->displayMediaApi() : ''; ////////// if ($post->image != '') { $doc = new DOMDocument(); $doc->loadHTML($post->image); $xpath = new DOMXPath($doc); $src = $xpath->evaluate("string(//img/@src)"); $post->image = $src; } ///////// //$post->mission_completed = true; //print_r(); // set display mission if ($post[0]->display_mission == 1) { $post->display_mission = true; } // get the groupid $groupid = GroupUser::where('user_id', '=', $user['id'])->pluck('group_id'); // get the taskid $taskid = $post[0]->task_id; // get the outcome id $group = Group::find($groupid); $outcomeid = Outcome::find($group->outcome)->id; // execute query $userTaskArray = DB::table('user_tasks')->where('outcome_id', $outcomeid)->where('user_id', $user['id'])->where('group_id', $groupid)->where('task_id', $taskid)->where('complete', 1)->get(); //print_r(count($userTaskArray)); if (count($userTaskArray) > 0) { $post->mission_completed = true; $post->general = false; } else { $post->mission_completed = false; $post->general = true; } return json_encode($post); }
public static function deleteGroup(Group $group) { Rating::where("[entityId] = ? AND [entityType] = ?", [$group->id, Group::ENTITY_TYPE])->delete(); RatingStatistic::where("[entityId] = ? AND [entityType] = ?", [$group->id, Group::ENTITY_TYPE])->delete(); Counter::where("[entityId] = ? AND [entityTypeId] = ?", [$group->id, Group::ENTITY_TYPE])->delete(); $topics = Topic::find("groupId", $group->id)->all(); foreach ($topics as $topic) { $topic->delete(); } GroupUser::where("[groupId] = ?", $group->id)->delete(); $group->delete(); }