checkComment($id); return $this->handleComment($comment); } protected function handleComment(CommentModel $comment) { $owner = $this->handleOwnerInfo($comment); return [ 'id' => $comment->id, 'owner' => $owner, 'content' => $comment->content, 'create_time' => $comment->create_time, ]; } protected function handleOwnerInfo(CommentModel $comment) { $userRepo = new UserRepo(); $owner = $userRepo->findById($comment->owner_id); return [ 'id' => $owner->id, 'name' => $owner->name, 'avatar' => $owner->avatar, ]; } }