'boolean', 'is_featured' => 'boolean', 'published_at' => 'datetime', 'file_size' => 'integer', 'download_count' => 'integer', ]; } public function scopePublished($query) { return $query->where('is_published', true)->whereNotNull('file_path')->whereNotNull('published_at'); } public function getFormattedSizeAttribute(): string { $bytes = (int) $this->file_size; if ($bytes < 1024) return $bytes.' B'; if ($bytes < 1048576) return number_format($bytes / 1024, 1).' KB'; if ($bytes < 1073741824) return number_format($bytes / 1048576, 1).' MB'; return number_format($bytes / 1073741824, 2).' GB'; } }