@php $toBase64 = function($path) { if (!$path) return null; $fullPath = storage_path('app/public/' . $path); if (file_exists($fullPath)) { return 'data:image/' . pathinfo($fullPath, PATHINFO_EXTENSION) . ';base64,' . base64_encode(file_get_contents($fullPath)); } return null; }; $profileBase64 = $toBase64($employee->profile_picture); $logoBase64 = $toBase64($employee->company->logo ?? null); // Barcode data $dataStr = "NAME:" . $employee->getFullNameAttribute() . "|ID:" . $employee->employee_id . "|PH:" . ($employee->phone_number ?? 'N/A') . "|E:" . $employee->email; try { $barcodeUrl = "https://bwipjs-api.metafloor.com/?bcid=code128&text=" . urlencode($dataStr) . "&scale=2&rotate=R&includetext=false"; $barcodeContent = @file_get_contents($barcodeUrl); if ($barcodeContent) { $barcodeBase64 = 'data:image/png;base64,' . base64_encode($barcodeContent); } else { $barcodeBase64 = null; } } catch (\Exception $e) { $barcodeBase64 = null; } @endphp
@if($logoBase64) @endif

{{ $employee->company->name ?? 'PUBLIC COMPANY' }}

{{ $employee->company->tagline ?? 'SECURITY SOLUTIONS' }}

@if($profileBase64) @else
{{ substr($employee->first_name, 0, 1) }}
@endif
@if($barcodeBase64) @else
NO BARCODE
@endif

{{ $employee->first_name }} {{ $employee->last_name }}

{{ $employee->jobRole->name ?? 'SECURITY GUARD' }}

Joining Date: {{ $employee->employment_date ? \Carbon\Carbon::parse($employee->employment_date)->format('d M, Y') : 'N/A' }}

ID: #{{ $employee->employee_id }}
License Expiry: {{ $employee->license_expiry ? \Carbon\Carbon::parse($employee->license_expiry)->format('d/m/Y') : 'PERMANENT' }}