@php
$bgFile = data_get($certificateSetting, 'page.background');
$bgUrl = null;
if ($bgFile) {
if (str_starts_with($bgFile, 'http')) $bgUrl = $bgFile;
else {
$possiblePaths = [
public_path('storage/' . $bgFile),
public_path('assets/images/certificate/' . $bgFile),
public_path('assets/images/certificate/background/default/' . $bgFile)
];
foreach($possiblePaths as $path) {
if (file_exists($path)) { $bgUrl = image_to_base64_print($path); break; }
}
}
}
@endphp
@if($bgUrl)
@foreach($certificateSetting as $key => $config)
@if($key === 'page' || $key === 'card' || !is_array($config) || !data_get($config, 'visible', true)) @continue @endif
@php
$dataKey = data_get($config, 'data_key');
$value = '';
if ($dataKey === 'qr' || $dataKey === 'qr_code') {
$qrValue = route('activity.verify-certificate', ['id' => $activity->id]) . '?certificate_id=' . urlencode((string) ($peserta->certificate_id ?? ''));
} else {
$value = get_cert_data_print($peserta, $dataKey, $activity);
if ($value === null && isset($config['text'])) $value = $config['text'];
}
$left = (float)data_get($config, 'left', 0) / $pxPerCmDesigner;
$top = (float)data_get($config, 'top', 0) / $pxPerCmDesigner;
$width = (float)data_get($config, 'width', 100) / $pxPerCmDesigner;
$height = (float)data_get($config, 'height', 40) / $pxPerCmDesigner;
$fontSize = (float)data_get($config, 'size', 16) / $pxPerCmDesigner;
@endphp
@if($dataKey === 'qr' || $dataKey === 'qr_code')
{!! QrCode::size(500)->format('svg')->generate($qrValue) !!}
@else
{!! nl2br(e($value)) !!}
@endif
@endforeach