diff --git a/app/Models/Food.php b/app/Models/Food.php index fdd894d..07a831d 100644 --- a/app/Models/Food.php +++ b/app/Models/Food.php @@ -156,8 +156,12 @@ final class Food extends Model /** * Get the serving size as a formatted string (e.g. 0.5 = 1/2). */ - public function getServingSizeFormattedAttribute(): string { - return Number::fractionStringFromFloat($this->serving_size); + public function getServingSizeFormattedAttribute(): ?string { + $result = null; + if (!empty($this->serving_size)) { + $result = Number::fractionStringFromFloat($this->serving_size); + } + return $result; } /** diff --git a/resources/views/foods/edit.blade.php b/resources/views/foods/edit.blade.php index 2f39ddc..faf1aa1 100644 --- a/resources/views/foods/edit.blade.php +++ b/resources/views/foods/edit.blade.php @@ -46,13 +46,6 @@