@php $zpLocale = $locale ?? app()->getLocale(); $zpRead = static function ($value) use ($zpLocale): string { if (is_array($value)) { if (array_key_exists('value', $value)) { $value = $value['value']; } if (is_array($value)) { return (string) ($value[$zpLocale] ?? reset($value) ?: ''); } } return is_scalar($value) ? (string) $value : ''; }; $zpReadableFields = static function (array $fields) use ($zpRead): array { $readable = []; foreach ($fields as $key => $value) { if (preg_match('/image|icon|url|link|color|class|file|video/i', (string) $key)) { continue; } $text = $zpRead($value); if ($text !== '') { $readable[(string) $key] = $text; } } return $readable; }; $zpMainFields = $zpReadableFields($data); $zpHeading = $zpRead($data['heading'] ?? $data['title'] ?? $data['section_title'] ?? null); $zpSubheading = $zpRead($data['subheading'] ?? $data['subtitle'] ?? null); $zpDescription = $zpRead($data['description'] ?? $data['text'] ?? null); $zpOtherCopy = []; foreach ($zpMainFields as $key => $text) { if (! preg_match('/heading|title|subheading|subtitle|description|text|button/i', $key)) { $zpOtherCopy[] = $text; } if ($zpHeading === '' && preg_match('/heading|title|name/i', $key)) { $zpHeading = $text; } if ($zpDescription === '' && preg_match('/description|text|content|body/i', $key)) { $zpDescription = $text; } } if ($zpDescription === '' && $zpOtherCopy !== []) { $zpDescription = implode(' ', $zpOtherCopy); } $zpItems = $repeatedContents ?? collect(); $zpComponent = strtolower((string) ($component->component_key ?? '')); $zpActionText = $zpRead($data['button_text'] ?? $data['action_text'] ?? null); $zpActionUrl = $zpRead($data['button_url'] ?? $data['action_url'] ?? null) ?: route('user.register'); @endphp
@if($zpSubheading)

{{ $zpSubheading }}

@endif @if($zpHeading)

{{ $zpHeading }}

@endif @if($zpDescription)

{{ $zpDescription }}

@endif
@if($zpActionText) {{ $zpActionText }} @endif @if($zpItems->isNotEmpty())
@foreach($zpItems as $index => $item) @php $zpItem = $item->content_data ?? $item->content ?? []; @endphp @php $zpItemFields = $zpReadableFields(is_array($zpItem) ? $zpItem : []); $zpItemTitle = ''; $zpItemCopy = []; foreach ($zpItemFields as $key => $text) { if ($zpItemTitle === '' && preg_match('/title|heading|name/i', $key)) { $zpItemTitle = $text; } elseif (preg_match('/text|description|content|body/i', $key)) { $zpItemCopy[] = $text; } } if ($zpItemTitle === '' && $zpItemFields !== []) { $zpItemTitle = reset($zpItemFields); } if ($zpItemCopy === []) { $zpItemCopy = array_slice(array_values($zpItemFields), 1); } @endphp
{{ str_pad((string) ($index + 1), 2, '0', STR_PAD_LEFT) }} @if($zpItemTitle)

{{ $zpItemTitle }}

@endif @if($zpItemCopy !== [])

{{ implode(' ', $zpItemCopy) }}

@endif
@endforeach
@endif