From 9f5c2b74eb78ee7a174859d378a115abec310657 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 21 Aug 2017 08:44:04 +0200 Subject: [PATCH] Fix division by zero. --- app/Repositories/Tag/TagRepository.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php index 01910c3a0f..ee0e6fe374 100644 --- a/app/Repositories/Tag/TagRepository.php +++ b/app/Repositories/Tag/TagRepository.php @@ -283,7 +283,7 @@ class TagRepository implements TagRepositoryInterface if (is_null($year)) { $query->whereNull('date'); } - $tags = $query->orderBy('id','desc')->get(); + $tags = $query->orderBy('id', 'desc')->get(); $temporary = []; foreach ($tags as $tag) { $amount = floatval($this->sumOfTag($tag, null, null)); @@ -339,8 +339,12 @@ class TagRepository implements TagRepositoryInterface { $amountDiff = $max - $min; $diff = $range[1] - $range[0]; - $step = $amountDiff / $diff; - $extra = round($amount / $step); + $step = 1; + if ($diff !== 0) { + $step = $amountDiff / $diff; + } + + $extra = round($amount / $step); return intval($range[0] + $extra); }