uid = $uid; $this->invite_code = $invite_code; } public function transform(Post $post) { $isLike = 0; $isDislike = 0; $isCollect = 0; if($this->uid){ $isLike = Redis::SISMEMBER('post_like_'.$post['id'], $this->uid); $isDislike = Redis::SISMEMBER('post_unlike_'.$post['id'], $this->uid); $isCollect = Redis::SISMEMBER('post_collect_'.$post['id'], $this->uid); } $user = $this->userInfo($post['uid']); $postInfo = $this->getPostInfo($post['id']); if($post['type']=='html'){ $content = subtext($post['content'],100); }else{ $content = $post['content']; } return [ 'id' => $post['id'], 'type' => $post['type'], 'created_at' => Carbon::parse($post['created_at'])->diffForHumans(), 'uid' => $post['uid'], 'username' => $user['username'], 'avatar' => $user['avatar'], 'topic' => $this->getTopic($post['topic_ids']), 'is_fine' => $post['is_fine'], 'title' => $post['title'], 'content' => $content, 'location' => $post['location'], 'img' => $post['img'], 'imgs' => $postInfo['imgs'], 'video' => $post['video'], 'pv' => getNumber($postInfo['pv']), 'praise_count' => $postInfo['praise_count'], 'comment_count' => $postInfo['comment_count'], 'collect_count' => $postInfo['collect_count'], 'will_collect_bean' => $postInfo['will_collect_bean'], 'is_like' => $isLike, 'is_dislike' => $isDislike, 'is_collect' => $isCollect, 'comment' => $this->getNewComment($post['id'], $this->uid), 'is_follow' => $this->getFollowStatus($this->uid, $post['uid']), 'h5url' => config('customer.share_post_h5url')."?post_id={$post['id']}&invite_code={$this->invite_code}", 'desc_url' => $post['type'] == 'html'?config('customer.app_service_url').'/community/fragment/detail/'.$post['id']:'', ]; } }