uid = $uid; $this->invite_code = $invite_code; } public function transform(Post $post) { $isFollow = 0; $followStatus = $this->getFollowStatus($this->uid, $post['uid']); if($followStatus){ $isFollow = $followStatus; } $topic = []; foreach($post->topic() as $key => $val){ $topic[] = [ 'id' => $key, 'name' => $val ]; } return [ 'id' => $post['id'], 'type' => $post['type'], 'uid' => $post['uid'], 'username' => $post['username'], 'avatar' => $post['avatar'], 'title' => $post['title'], 'content' => $post['content'], 'img' => $post['img'], 'video' => $post['video'], 'topic' => $topic, 'praise_count' => $post->data->praise_count, 'collect_count' => $post->data->collect_count, 'comment_count' => $post->data->comment_count, 'will_collect_bean' => $post->data->will_collect_bean + 3 * $post->data->pv, 'is_like' => PostLike::where('post_id', $post['id'])->where('uid', $this->uid)->exists()?1:0, 'is_collect' => PostCollect::where('post_id', $post['id'])->where('uid', $this->uid)->exists()?1:0, 'is_follow' => $isFollow, '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']:'', ]; } }