@php if ($team->backgroundImage) { $backgroundPath = storage_path('app/public' . $team->backgroundImage->url); $mimeType = $team->backgroundImage->media_type ?? 'image/png'; } else { $backgroundPath = public_path('/img/certificate_' . $direction . '.png'); $mimeType = 'image/png'; } if (file_exists($backgroundPath)) { $backgroundData = base64_encode(file_get_contents($backgroundPath)); $background = "data:" . $mimeType . ";base64," . $backgroundData; } else { // Fallback to default if custom background is missing $backgroundPath = public_path('/img/certificate_' . $direction . '.png'); if (file_exists($backgroundPath)) { $backgroundData = base64_encode(file_get_contents($backgroundPath)); $background = "data:image/png;base64," . $backgroundData; } else { $background = ""; } } @endphp