@php $widthCmDefault = (float) data_get($certificateSetting, 'card.width_cm', 21); $heightCmDefault = (float) data_get($certificateSetting, 'card.height_cm', 29.7); $bgFilenameGlobal = data_get($certificateSetting, 'card.background'); if (!function_exists('image_to_base64_data_uri')) { function image_to_base64_data_uri($path) { if (!file_exists($path) || !is_readable($path)) { return null; } $type = mime_content_type($path); if ($type === false) { $type = 'image/' . pathinfo($path, PATHINFO_EXTENSION); } $data = file_get_contents($path); return 'data:' . $type . ';base64,' . base64_encode($data); } } $certificatesPerPage = max(1, (int)($cols * $rows)); @endphp
@foreach($participants->chunk($certificatesPerPage) as $pageIndex => $page) @if($pageIndex > 0)
@endif @foreach($page->chunk($cols) as $rowIndex => $row)
@foreach($row as $peserta) @php $profileParticipant = optional(optional($peserta)->user)->profile; $provinceParticipant = optional($profileParticipant->province)->name ?? ($profileParticipant->other_province ?? null); $widthCm = $widthCmDefault; $heightCm = $heightCmDefault; $bgFilename = $bgFilenameGlobal; $bgPath = $bgFilename ? public_path('assets/images/certificate/' . $bgFilename) : public_path('assets/images/certificate/default-certificate.png'); $bgBase64 = image_to_base64_data_uri($bgPath); $titleStyle = data_get($certificateSetting, 'title', []); $photoStyle = data_get($certificateSetting, 'photo', []); $qrStyle = data_get($certificateSetting, 'qr', []); $photoSizeSetting = (int) data_get($photoStyle, 'size', 90); $photoShape = data_get($photoStyle, 'shape', 'square'); $photoFilename = optional($profileParticipant)->foto; $photoPath = $photoFilename ? public_path('assets/images/profilefoto/' . $photoFilename) : public_path('assets/images/profilefoto/default-profile.png'); $photoBase64 = image_to_base64_data_uri($photoPath); $overlayColor = data_get($photoStyle, 'overlay_color', '#000000'); $overlayOpacity = (int) data_get($photoStyle, 'overlay_opacity', 0); $overlayAlpha = max(0, min(100, $overlayOpacity)) / 100.0; $qrTop = (int) data_get($qrStyle, 'top', 320); $qrLeft = (int) data_get($qrStyle, 'left', 90); $qrSizeInput = (int) data_get($qrStyle, 'size', 80); $qrSize = max(40, $qrSizeInput); @endphp
@if($bgBase64) Certificate Background @endif
@if(data_get($titleStyle, 'visible', true))
{{ str_replace(["\r\n","\n"], ' ', ($activity->name ?? 'Sertifikat PESERTA')) }}
@endif @if(data_get($certificateSetting, 'name.visible', false))
{{ optional(optional($peserta)->user)->name ?? '-' }}
@endif @if(data_get($certificateSetting, 'email.visible', false))
{{ optional(optional($peserta)->user)->email ?? '-' }}
@endif @if(data_get($certificateSetting, 'no_hp.visible', false))
{{ optional($profileParticipant)->no_hp ?? '-' }}
@endif @if(data_get($certificateSetting, 'jenis_kelamin.visible', false))
{{ optional($profileParticipant)->jenis_kelamin ?? '-' }}
@endif @if(data_get($certificateSetting, 'pekerjaan.visible', false))
{{ optional($profileParticipant)->pekerjaan ?? '-' }}
@endif @if(data_get($certificateSetting, 'jabatan.visible', false))
{{ optional($profileParticipant)->jabatan ?? '-' }}
@endif @if(data_get($certificateSetting, 'alamat.visible', false))
{{ optional($profileParticipant)->alamat ?? '-' }}
@endif @if(data_get($certificateSetting, 'province.visible', false))
{{ $provinceParticipant ?? '-' }}
@endif @if(data_get($certificateSetting, 'certificate_id.visible', false))
{{ $peserta->certificate_id ?? '-' }}
@endif @if(data_get($photoStyle, 'visible', true))
@if($photoBase64) Foto
@endif
@endif
@php $qrVal = route('activity.download-certificate', ['id' => $activity->id]) . '?show_certificate=1'; try { $qrBinary = \SimpleSoftwareIO\QrCode\Facades\QrCode::format('png')->size(max($qrSize,40))->generate((string) $qrVal); $qrSrc = 'data:image/png;base64,'.base64_encode($qrBinary); } catch (\Throwable $e) { $qrSrc = 'https://api.qrserver.com/v1/create-qr-code/?size='.max($qrSize,40).'x'.max($qrSize,40).'&data='.urlencode((string) $qrVal); } @endphp QR Code
@endforeach @if(count($row) < $cols) @for($i = 0; $i < $cols - count($row); $i++)
@endfor @endif
@endforeach @endforeach