This commit is contained in:
James Cole
2018-06-01 13:11:10 +02:00
parent 3654e75b8c
commit 4c04415e80
5 changed files with 27 additions and 18 deletions

View File

@@ -145,27 +145,18 @@ class TagController extends Controller
public function index(TagRepositoryInterface $repository)
{
// start with oldest tag
$oldestTag = $repository->oldestTag();
/** @var Carbon $start */
$start = new Carbon;
if (null !== $oldestTag) {
/** @var Carbon $start */
$start = $oldestTag->date; // @codeCoverageIgnore
}
if (null === $oldestTag) {
/** @var Carbon $start */
$start = clone session('first');
}
$now = new Carbon;
$oldestTagDate = null === $repository->oldestTag() ? clone session('first') : $repository->oldestTag()->date;
$newestTagDate = null === $repository->newestTag() ? new Carbon : $repository->newestTag()->date;
$oldestTagDate->startOfYear();
$newestTagDate->endOfYear();
$clouds = [];
$clouds['no-date'] = $repository->tagCloud(null);
while ($now > $start) {
$year = $now->year;
while ($newestTagDate > $oldestTagDate) {
$year = $newestTagDate->year;
$clouds[$year] = $repository->tagCloud($year);
$now->subYear();
$newestTagDate->subYear();
}
$count = $repository->count();