@php $attachments = collect($attachments ?? []); $filesBaseUrl = rtrim((string) config('cdn.files_url', ''), '/'); $toUrl = function (?string $path) use ($filesBaseUrl): string { $cleanPath = ltrim((string) $path, '/'); return $filesBaseUrl !== '' ? ($filesBaseUrl . '/' . $cleanPath) : ('/' . $cleanPath); }; $formatBytes = function ($bytes): string { $size = max((int) $bytes, 0); if ($size < 1024) { return $size . ' B'; } $units = ['KB', 'MB', 'GB']; $value = $size / 1024; $unitIndex = 0; while ($value >= 1024 && $unitIndex < count($units) - 1) { $value /= 1024; $unitIndex++; } return number_format($value, 1) . ' ' . $units[$unitIndex]; }; @endphp @if ($attachments->isNotEmpty())