@php $hexToRgba = function (?string $hex, float $alpha = 1.0): string { if (!$hex) { $hex = '#000000'; } if ($hex === 'transparent') { return 'transparent'; } $normalized = ltrim($hex, '#'); if (strlen($normalized) === 3) { $normalized = implode('', array_map(fn ($char) => $char . $char, str_split($normalized))); } $int = hexdec($normalized); $r = ($int >> 16) & 255; $g = ($int >> 8) & 255; $b = $int & 255; return sprintf('rgba(%d, %d, %d, %.2f)', $r, $g, $b, $alpha); }; @endphp @foreach($blocksByPage as $pageNum => $blocks) @php $pageBackground = $backgrounds[$pageNum] ?? null; $pageStyle = 'position: relative;'; if ($pageBackground && !empty($pageBackground['path']) && file_exists($pageBackground['path'])) { $pageStyle .= "background-image: url('".$pageBackground['path']."'); background-size: cover; background-position: center;"; } @endphp
@foreach($blocks as $data) @php $position = $data->position; $json = $data->json ?? []; $imageSource = null; if (!empty($json['is_image'])) { if (!empty($json['image_absolute_path']) && file_exists($json['image_absolute_path'])) { $imageSource = $json['image_absolute_path']; } elseif (!empty($json['image_path']) && \Illuminate\Support\Facades\Storage::disk('public')->exists($json['image_path'])) { $imageSource = \Illuminate\Support\Facades\Storage::disk('public')->path($json['image_path']); } elseif (!empty($json['image_url'])) { $imageSource = $json['image_url']; } } @endphp
@if(!empty($json['is_image']) && $imageSource) Bloc image @else {!! $json['content'] ?? '' !!} @endif
@endforeach
@endforeach @if(empty($blocksByPage))

Document vide

@endif