'boolean', 'sort_order' => 'integer', 'file_size' => 'integer', ]; /** * کاربری که فایل را آپلود کرده */ public function uploader(): BelongsTo { return $this->belongsTo(User::class, 'uploaded_by'); } /** * آدرس کامل فایل */ public function getFileUrlAttribute(): string { return asset('storage/' . $this->file_path); } /** * فرمت حجم فایل */ public function getFormattedSizeAttribute(): string { $bytes = $this->file_size; $units = ['B', 'KB', 'MB', 'GB']; for ($i = 0; $bytes >= 1024 && $i < count($units) - 1; $i++) { $bytes /= 1024; } return round($bytes, 2) . ' ' . $units[$i]; } }