{{ ($recipe->exists ? "Edit {$recipe->name}" : 'Add Recipe') }}

@if ($recipe->exists)@method('put')@endif @csrf

Ingredients

@if(old('ingredients')) @foreach(old('ingredients') as $i => $ingredient) @if (empty($ingredient) && empty(old('ingredients_amount')[$i]) && empty(old('ingredients_unit')[$i])) @continue @endif @include('recipes.partials.ingredient-input', [ 'amount' => old('ingredients_amount')[$i], 'unit' => old('ingredients_unit')[$i], 'food_id' => old('ingredients')[$i], 'food_name' => old('ingredients_name')[$i], 'detail' => old('ingredients_detail')[$i], ]) @endforeach @else @foreach($recipe->foodAmounts as $foodAmount) @include('recipes.partials.ingredient-input', [ 'amount' => $foodAmount->amount_formatted, 'unit' => $foodAmount->unit, 'food_id' => $foodAmount->food->id, 'food_name' => $foodAmount->food->name, 'detail' => $foodAmount->detail, ]) @endforeach @endif

Steps

@if(old('steps')) @foreach(old('steps') as $i => $step_default) @if (empty($step)) @continue @endif @include('recipes.partials.step-input') @endforeach @else @foreach($recipe->steps as $step) @include('recipes.partials.step-input', ['step_default' => $step->step]) @endforeach @endif
{{ ($recipe->exists ? 'Save' : 'Add') }}