public function getByPostId($post_id, Vote $vote) { $comments = Cache::remember(Constant::COMMENT_CACHE_NEWLIST_NAME . $post_id, Constant::COMMENT_CACHE_NEWLIST_MINS, function () use($post_id) { return DB::table('comments')->join('users', 'comments.user_id', '=', 'users.id')->select('comments.id', 'comments.post_id', 'comments.user_id', 'comments.created_at', 'comments.updated_at', 'comments.deleted_at', 'comments.upvotes', 'comments.downvotes', 'comments.parent_id', 'comments.data', 'comments.markdown', 'users.username', 'users.points', 'users.id AS users_user_id', 'users.votes', 'users.anonymous')->where('post_id', '=', $post_id)->orderBy('id', 'asc')->get(); }); F::each($comments, function ($v) { if ($v->deleted_at != 0) { $v->username = "******"; $v->data = "<p>user deleted this comment</p>"; $v->markdown = "user deleted this comment"; } return $v; }); return $vote->applySelection($comments, $vote->COMMENT_TYPE); }
public function getControversialList(array $section_ids = [0], $seconds, Vote $vote) { return $vote->applySelection($this->getList($section_ids, $seconds, Constant::SORT_ORDERBY_SQL_CONTROVERSIAL, $vote), Constant::POST_TYPE); }