@php $firmLogoData = null; $companyLogoPath = null; $company = $company ?? \App\Models\CompanySettings::query()->first(); if (!empty($company?->firm_logo_path)) { $companyLogoPath = $company->firm_logo_path; } else { $firmLogoDir = public_path('firm-logo'); if (is_dir($firmLogoDir)) { $files = glob($firmLogoDir . '/*'); if (!empty($files)) { sort($files); $companyLogoPath = $files[0]; } } } if (!empty($companyLogoPath)) { $companyLogoPath = str_replace('\\', '/', $companyLogoPath); $isAbsolute = str_starts_with($companyLogoPath, '/') || preg_match('/^[A-Za-z]:\\//', $companyLogoPath) === 1; $absolutePath = $isAbsolute ? $companyLogoPath : public_path($companyLogoPath); if (file_exists($absolutePath)) { $ext = strtolower(pathinfo($absolutePath, PATHINFO_EXTENSION)); if ($ext === 'svg') { $mime = 'svg+xml'; } elseif ($ext === 'webp') { $mime = 'webp'; } elseif (in_array($ext, ['jpg', 'jpeg'], true)) { $mime = 'jpeg'; } else { $mime = 'png'; } $firmLogoData = 'data:image/' . $mime . ';base64,' . base64_encode(file_get_contents($absolutePath)); } } @endphp