@php use App\Modules\Pages\Builder\BlockContext; use App\Modules\Pages\Builder\BlockRegistry; $ctx = $ctx ?? app(BlockContext::class); $preview = $preview ?? false; $pageTitle = $pageTitle ?? null; $url = fn (?string $path) => BlockContext::url($path); $href = fn (?string $link, string $fallback = '') => BlockContext::href($link, $fallback); $lines = fn ($value) => array_values(array_filter(array_map('trim', preg_split('/\R/', (string) $value) ?: []))); $crumbs = $crumbs ?? null; $position = 0; @endphp @foreach($sections as $section) @php $type = (string) ($section['type'] ?? ''); $skip = ! ($section['visible'] ?? true) || ! BlockRegistry::has($type) || ! view()->exists('builder.blocks.'.$type); @endphp @continue($skip) @php $settings = $section['settings'] ?? []; $vis = trim(implode(' ', array_filter([ ! empty($settings['hide_mobile']) ? 'pb-hide-mobile' : null, ! empty($settings['hide_desktop']) ? 'pb-hide-desktop' : null, ]))); $cls = trim(BlockContext::sectionClass($settings).' pb-section pb-section--'.$type.' '.$vis); $attrs = new \Illuminate\Support\HtmlString(trim( (! empty($settings['anchor']) ? 'id="'.e($settings['anchor']).'" ' : '') .($preview ? 'data-pb-uid="'.e($section['uid'] ?? '').'"' : '') )); $position++; @endphp @include('builder.blocks.'.$type, [ 'data' => $section['data'] ?? [], 'settings' => $settings, 'section' => $section, 'first' => $position === 1, ]) @endforeach