/** * @param PosterInterface $poster * @param AtomInterface $about * @param int $limit * * @return LikeResult */ public function getLikeResult(PosterInterface $poster = null, AtomInterface $about, $limit = 3) { if (null == $poster) { $poster = app()->auth()->getViewer(); } $isLiked = false; $likeCount = $about->getLikeCount(); if ($poster && $likeCount) { $isLiked = $this->isLiked($poster, $about); } $sample = []; if ($isLiked) { } if ($likeCount > 0) { $select = app()->table('platform_like')->select()->where('about_id=?', $about->getId())->where('about_type=?', $about->getType())->limit($limit, 0); if ($poster != null) { $select->where('poster_id <>?', $poster->getId()); } foreach ($select->all() as $like) { if (!$like instanceof Like) { continue; } if (null != ($likedPoster = $like->getPoster())) { $sample[] = $likedPoster; } } } return new LikeResult($isLiked, $likeCount, $sample, $about); }