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,10 +46,12 @@ class JournalEntryController extends Controller
|
||||||
$goalProgress = [];
|
$goalProgress = [];
|
||||||
if ($goal) {
|
if ($goal) {
|
||||||
foreach (Nutrients::all()->pluck('value') as $nutrient) {
|
foreach (Nutrients::all()->pluck('value') as $nutrient) {
|
||||||
|
if ($goal->{$nutrient} > 0) {
|
||||||
$goalProgress[$nutrient] = round($sums[$nutrient] / $goal->{$nutrient} * 100);
|
$goalProgress[$nutrient] = round($sums[$nutrient] / $goal->{$nutrient} * 100);
|
||||||
$goalProgress[$nutrient] .= '%';
|
$goalProgress[$nutrient] .= '%';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return view('journal-entries.index')
|
return view('journal-entries.index')
|
||||||
->with('entries', $entries)
|
->with('entries', $entries)
|
||||||
|
|
Loading…
Reference in New Issue