$this->id, 'filename' => $this->filename, 'filepath' => $this->filepath, 'mime_type' => $this->mime_type, 'size' => $this->size, 'size_human' => $this->formatBytes($this->size), 'created_at' => $this->created_at->toISOString(), ]; } private function formatBytes($bytes, $precision = 2) { $units = ['B', 'KB', 'MB', 'GB', 'TB']; for ($i = 0; $bytes > 1024 && $i < count($units) - 1; $i++) { $bytes /= 1024; } return round($bytes, $precision) . ' ' . $units[$i]; } }