@php $certificateRecord = $certificate ?? ($deposit ?? null); $certificateRecord = $certificateRecord instanceof \Illuminate\Support\Collection ? $certificateRecord->first() : ($certificateRecord[0] ?? $certificateRecord); $instructorTitle = $certificateRecord->instructor_name ?? $certificateRecord->title ?? null; $certificateName = $certificateRecord->certificate_name ?? ($user->phone_number ?? ''); $companyName = $certificateRecord->company_name ?? $certificateRecord->company ?? ''; $issueDate = $certificateRecord->issue_date ?? $certificateRecord->ondate ?? null; $validFrom = $certificateRecord->valid_from ?? $certificateRecord->startDate ?? null; $validUntil = $certificateRecord->valid_until ?? $certificateRecord->endDate ?? null; $referenceYear = $issueDate ? date('Y', strtotime($issueDate)) : date('Y', strtotime($user->created_at ?? 'now')); $certificateNumber = $certificateRecord->certificate_number ?? 'IMM/'.$referenceYear.$user->id; $cardNumber = $certificateRecord->card_number ?? 'IMM/TC/'.$user->id; $formatCertificateDate = function ($value) { return $value ? date('d-m-Y', strtotime($value)) : ''; }; $imageDataUri = function ($path) { $path = ltrim((string) $path, '/'); $fullPath = public_path($path); if (! $path || ! is_file($fullPath)) { return ''; } return 'data:'.mime_content_type($fullPath).';base64,'.base64_encode(file_get_contents($fullPath)); }; $backgroundImage = ''; if ($instructorTitle == 'Muhammad Zaid') { $backgroundImage = 'zaid.png'; } elseif ($instructorTitle == 'Shahbaz Tabassum') { $backgroundImage = 'shahbaz.png'; } elseif ($instructorTitle == 'Moazzam Ali') { $backgroundImage = 'moazzam.png'; } elseif ($instructorTitle == 'Waqar Azeem') { $backgroundImage = 'waqar.png'; } elseif ($instructorTitle == 'Tariq Jamal') { $backgroundImage = 'tariq.png'; } else { $backgroundImage = 'certficate-pdf.png'; // Fallback image } $backgroundImageSrc = $imageDataUri('assets/img/'.$backgroundImage); $cardBackgroundSrc = $imageDataUri('assets/img/card-pdf.png'); $profilePhotoSrc = $imageDataUri($user->profile_photo); $qrCodeData = $user->qr_code ?? ''; $decodedQrCode = $qrCodeData ? base64_decode($qrCodeData, true) : ''; $qrCodeMime = $decodedQrCode && strpos(ltrim($decodedQrCode), ' IMMUSCO Oil Field Equipment LLC
@if ($profilePhotoSrc) Profile Photo @endif
{{ $certificateNumber }} {{ $user->name }} {{ $user->name }} {{ $user->nic }} {{ $certificateName }} {{ $certificateName }}
QR Code
{{ $formatCertificateDate($validFrom) }} {{ $formatCertificateDate($validUntil) }}
{{ $cardNumber }}
@if ($profilePhotoSrc) Profile Photo @endif
{{ $user->name }}
{{ $certificateName }}
{{ $certificateNumber }}
{{ $user->nic }}
{{ $companyName }}
{{ $formatCertificateDate($validUntil) }}