/** * 用户动态 * GET /posts/user_timeline * @param PostsInterface $postInterface * @return mixed */ public function getUserTimeline(PostsInterface $postInterface) { $maxId = maxId(); $sinceId = sinceId(); $pageSize = pageSize(); $userId = inputGet('user_id'); // if null if ($userId) { $data = $postInterface->getUserPosts($userId, $sinceId, $maxId, $pageSize); return respondWithCollection($data, new PostsTransformer()); } $user = user(); if (is_null($user)) { errorUnauthorized(); } $data = $postInterface->getMyPosts($user->id, $sinceId, $maxId, $pageSize); return respondWithCollection($data, new MyPostsTransformer()); }
/** * /GET /comments/{post_id} * @param CommentsTransformer $commentsTransformer * @param $postId * @return mixed */ public function index(CommentsTransformer $commentsTransformer, $postId) { $data = $this->commentsInterface->getComments($postId, sinceId(), maxId(), pageSize()); return respondWithCollection($data, $commentsTransformer); }