@php $recipe ??= null; $initialIngredients = old('ingredients', $recipe?->ingredients->map(fn ($i) => [ 'id' => $i->id, 'name' => $i->name, 'quantity' => $i->quantity, 'media' => $i->media->map(fn ($m) => ['id' => $m->id, 'url' => $m->url()])->toArray(), ])->toArray() ?? []); $initialSteps = old('steps', $recipe?->steps->map(fn ($s) => [ 'id' => $s->id, 'name' => $s->name, 'description' => $s->description, 'media' => $s->media->map(fn ($m) => ['id' => $m->id, 'url' => $m->url()])->toArray(), ])->toArray() ?? []); if (empty($initialIngredients)) { $initialIngredients = [['id' => null, 'name' => '', 'quantity' => '', 'media' => []]]; } if (empty($initialSteps)) { $initialSteps = [['id' => null, 'name' => '', 'description' => '', 'media' => []]]; } $initialTags = old('tags', $recipe?->tags->pluck('name')->implode(', ')); @endphp
@php $difficulty = old('difficulty', $recipe?->difficulty ?? 'easy'); @endphp
@php $selectedCategory = old('category_id', $recipe?->category_id); @endphp
public) ? 'checked' : '' }} class="rounded border-gray-300 text-gray-800 shadow-sm focus:ring-gray-800">