@php use App\Services\MediaService; @endphp @foreach ($customFields as $field) @php $fieldValues = $productCustomFieldValues[$field->id] ?? collect(); $fieldValues = $fieldValues->isEmpty() ? collect([null]) : $fieldValues; @endphp
@foreach ($fieldValues as $i => $fieldValue)
@switch($field->type) @case('text') @break @case('number') @break {{-- @case('file')
@if (!empty($fieldValue->value)) @php $isPublicDisk = 1; $imagePath = $isPublicDisk ? asset(config('constants.CUSTOM_FIELD_FILE_PATH') . $fieldValue->value) : $fieldValue->value; @endphp
uploaded image
@endif @break --}} @case('file')
{{-- Add this hidden input to retain old file value --}} @if (!empty($fieldValue->value)) @endif
@if (!empty($fieldValue->value)) @php $isPublicDisk = 1; $imagePath = $isPublicDisk ? asset(config('constants.CUSTOM_FIELD_FILE_PATH') . $fieldValue->value) : $fieldValue->value; @endphp
uploaded image
@endif @break @case('date') @break @case('dropdown') @break @case('radio') @foreach ($field->options ?? [] as $opt) @endforeach @break @case('checkbox') @php $selected = json_decode($fieldValue->value ?? '[]', true) ?? []; @endphp @foreach ($field->options ?? [] as $opt) @endforeach @break @case('color') @break @case('textarea') @break @endswitch @if (!$field->required) @endif
@endforeach
{{-- Always show add button --}}
@endforeach