mirror of https://github.com/kcal-app/kcal.git
Prevent potential division by zero error
This commit is contained in:
parent
86b61dba30
commit
ce9bf83221
|
@ -46,8 +46,10 @@ class JournalEntryController extends Controller
|
||||||
$goalProgress = [];
|
$goalProgress = [];
|
||||||
if ($goal) {
|
if ($goal) {
|
||||||
foreach (Nutrients::all()->pluck('value') as $nutrient) {
|
foreach (Nutrients::all()->pluck('value') as $nutrient) {
|
||||||
$goalProgress[$nutrient] = round($sums[$nutrient] / $goal->{$nutrient} * 100);
|
if ($goal->{$nutrient} > 0) {
|
||||||
$goalProgress[$nutrient] .= '%';
|
$goalProgress[$nutrient] = round($sums[$nutrient] / $goal->{$nutrient} * 100);
|
||||||
|
$goalProgress[$nutrient] .= '%';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue