postId = $postId; $this->uid = $uid; } public function transform(PostComment $postComment) { $user = $this->userInfo($postComment['uid']); $replyUsername = ''; if($postComment['reply_uid']){ $userReply = $this->userInfo($postComment['reply_uid']); $replyUsername = $userReply['username']; } $commentLike = $this->getCommentLike($this->postId, $postComment['id'], $this->uid); return [ 'id' => $postComment['id'], 'uid' => $postComment['uid'], 'username' => $user['username'], 'reply_username' => $replyUsername, 'avatar' => $user['avatar'], 'content' => $postComment['is_delete']?'该回复已被删除':$postComment['content'], 'created_at' => Carbon::parse($postComment['created_at'])->diffForHumans(), 'is_delete' => $postComment['is_delete'], 'is_like' => $commentLike['is_like'], 'like_count' => $commentLike['like_count'], ]; } }