@php $value = fn($field, $default = '') => old($field, optional($item)->$field ?? $default); $type = old('product_type', optional($item)->product_type ?? 'type2'); $featuresText = old('features_text', is_array(optional($item)->features) ? implode("\n", $item->features) : ''); $specPairs = old('spec_keys') ? collect(old('spec_keys'))->map(fn($key, $i) => ['label' => $key, 'value' => old('spec_values')[$i] ?? ''])->all() : (optional($item)->specification_pairs ?: [['label' => '', 'value' => '']]); $faqRows = old('faq_questions') ? collect(old('faq_questions'))->map(fn($key, $i) => ['question' => $key, 'answer' => old('faq_answers')[$i] ?? ''])->all() : (optional($item)->faq ?: [['question' => '', 'answer' => '']]); $catalogRows = old('catalog_title') ? collect(old('catalog_title'))->map(fn($title, $i) => [ 'group' => old('catalog_group')[$i] ?? '', 'code' => old('catalog_code')[$i] ?? '', 'title' => $title, 'image' => old('catalog_image')[$i] ?? '', ])->all() : (optional($item)->catalog_items ?: [['group' => '', 'code' => '', 'title' => '', 'image' => '']]); $typeLabels = ['type1' => 'E-commerce', 'type2' => 'Inquiry', 'type3' => 'Catalog']; $selectedImages = collect(old('selected_media', is_array(optional($item)->images) ? $item->images : []))->filter()->values(); $mediaFiles = collect($mediaFiles ?? []); $selectedDomainId = old('main_domain_id', optional(optional($item)->category)->parent_id ?: optional($item)->category_id); @endphp @extends('layouts.admin') @section('content')

{{ $item ? 'Edit product' : 'Add product' }}

{{ $item ? $item->name : 'New Product' }}

{{ $item ? 'Update product content, layout type and publishing details.' : 'Create a product in a guided form with only the relevant fields visible.' }}

Back to Products @if($item)Preview@endif
@csrf
Step 1

Select Product Type

@foreach($typeLabels as $key => $label) @endforeach
Step 2

Title, Category & Description

Step 3

Product Gallery

Gallery Images Use the media popup to select existing images, or upload new images while saving.
@forelse($selectedImages as $image)
Selected product image
{{ basename($image) }}
@empty

No images selected yet.

@endforelse
@foreach($selectedImages as $image) @unless($mediaFiles->contains('url', $image)) @endunless @endforeach
Step 4

Product Type Fields

Specifications
@foreach($specPairs as $row)
@endforeach
FAQ
@foreach($faqRows as $row)
@endforeach
Grouped Catalog Items
@foreach($catalogRows as $row)
@if(!empty($row['image']))Catalog item image{{ basename($row['image']) }}@elseNo image selected@endif
@endforeach
SEO

Publishing

Cancel
@endsection