@foreach($blocks as $data)
@php
$position = $data->position;
$json = $data->json ?? [];
$imageSource = null;
if (!empty($json['is_image'])) {
if (!empty($json['image_absolute_path'])) {
// Si c'est une donnée base64 ou une URL, l'utiliser directement
if (str_starts_with($json['image_absolute_path'], 'data:image/') ||
str_starts_with($json['image_absolute_path'], 'http://') ||
str_starts_with($json['image_absolute_path'], 'https://')) {
$imageSource = $json['image_absolute_path'];
} elseif (file_exists($json['image_absolute_path'])) {
// Si c'est un chemin local, l'utiliser directement
$imageSource = $json['image_absolute_path'];
}
}
// Fallback vers les autres options si image_absolute_path n'est pas disponible
if (!$imageSource) {
if (!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'];
}
}
}
// Décalage pour ajuster la position dans le PDF généré
// X : décaler vers la droite (augmenter)
// Y : décaler vers le haut (diminuer)
$offsetX = 5; // pixels vers la droite
$offsetY = -10; // pixels vers le haut
$adjustedX = $position ? (($position->x ?? 0) + $offsetX) : $offsetX;
$adjustedY = $position ? (($position->y ?? 0) + $offsetY) : $offsetY;
@endphp
@if(!empty($json['is_image']) && $imageSource)

@else
{!! $json['content'] ?? '' !!}
@endif
@endforeach
@endforeach