{{-- Disk sayfasının altındaki kullanılan alan özeti. Beklenen: $stats (DiskController::getStorageStatistics) --}} @php $fmt = function ($bytes) { $bytes = (float) $bytes; $units = ['B', 'KB', 'MB', 'GB', 'TB']; $i = 0; while ($bytes >= 1024 && $i < count($units) - 1) { $bytes /= 1024; $i++; } return ($i === 0 ? number_format($bytes, 0) : number_format($bytes, 1, ',', '.')) . ' ' . $units[$i]; }; $typeMeta = [ 'image' => ['Görseller', '#22c55e', 'fa-image'], 'document' => ['Belgeler', '#3b82f6', 'fa-file-alt'], 'spreadsheet' => ['Tablolar', '#10b981', 'fa-file-excel'], 'presentation' => ['Sunumlar', '#f97316', 'fa-file-powerpoint'], 'video' => ['Videolar', '#ef4444', 'fa-video'], 'audio' => ['Sesler', '#8b5cf6', 'fa-music'], 'archive' => ['Arşivler', '#f59e0b', 'fa-file-archive'], 'other' => ['Diğer', '#64748b', 'fa-file'], ]; $used = (int) ($stats['used_size'] ?? 0); $quota = (int) ($stats['quota_size'] ?? 0); $pct = (float) ($stats['used_percent'] ?? 0); $level = $pct >= 95 ? 'danger' : ($pct >= 80 ? 'warn' : 'ok'); $segments = []; foreach (($stats['by_type'] ?? collect()) as $type => $row) { [$label, $color, $icon] = $typeMeta[$type] ?? $typeMeta['other']; $segments[] = ['label' => $label, 'color' => $color, 'icon' => $icon, 'bytes' => (int) $row->size, 'count' => (int) $row->count]; } usort($segments, fn ($a, $b) => $b['bytes'] <=> $a['bytes']); if (($stats['versions_size'] ?? 0) > 0) { $segments[] = ['label' => 'Eski sürümler', 'color' => '#a855f7', 'icon' => 'fa-clock-rotate-left', 'bytes' => (int) $stats['versions_size'], 'count' => null]; } if (($stats['other_size'] ?? 0) > 0) { $segments[] = ['label' => 'Küçük resim ve diğer', 'color' => '#94a3b8', 'icon' => 'fa-images', 'bytes' => (int) $stats['other_size'], 'count' => null]; } @endphp