mirror of https://github.com/kcal-app/kcal.git
Default food nutrients to zero
This commit is contained in:
parent
3c5d1c1f00
commit
713da8f728
|
|
@ -93,6 +93,14 @@ class FoodController extends Controller
|
||||||
]);
|
]);
|
||||||
$attributes['serving_size'] = Number::floatFromString($attributes['serving_size']);
|
$attributes['serving_size'] = Number::floatFromString($attributes['serving_size']);
|
||||||
$attributes['name'] = Str::lower($attributes['name']);
|
$attributes['name'] = Str::lower($attributes['name']);
|
||||||
|
|
||||||
|
// Default nutrients to zero.
|
||||||
|
foreach (Nutrients::$all as $nutrient) {
|
||||||
|
if (is_null($attributes[$nutrient['value']])) {
|
||||||
|
$attributes[$nutrient['value']] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$food->fill($attributes)->save();
|
$food->fill($attributes)->save();
|
||||||
|
|
||||||
// Sync tags.
|
// Sync tags.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue