diff --git a/resources/views/recipes/show.blade.php b/resources/views/recipes/show.blade.php index 1fdd731..6642ca7 100644 --- a/resources/views/recipes/show.blade.php +++ b/resources/views/recipes/show.blade.php @@ -43,8 +43,18 @@ @if($item::class === \App\Models\IngredientAmount::class)
  • - {{ \App\Support\Number::rationalStringFromFloat($item->amount) }} - @if($item->unitFormatted){{ $item->unitFormatted }}@endif + {{-- Prevent food with serving size > 1 from incorrectly using formatted + serving unit with number of servings. E.g., for a recipe calling for 1 + serving of a food with 4 tbsp. to a serving size show "1 serving" instead + of "1 tbsp." (incorrect). --}} + @if($item->unit === 'serving' && $item->ingredient->serving_size > 1 && ($item->ingredient->serving_unit || $item->ingredient->serving_unit_name)) + {{ \App\Support\Number::rationalStringFromFloat($item->amount * $item->ingredient->serving_size) }} {{ $item->unitFormatted }} + ({{ \App\Support\Number::rationalStringFromFloat($item->amount) }} {{ \Illuminate\Support\Str::plural('serving', $item->amount ) }}) + @else + {{ \App\Support\Number::rationalStringFromFloat($item->amount) }} + @if($item->unitFormatted){{ $item->unitFormatted }}@endif + @endif + @if($item->ingredient->type === \App\Models\Recipe::class)