morphTo(); } public function user(): BelongsTo { return $this->belongsTo(User::class); } public function publicUrl(): string { if ($this->disk === 'public') { return asset('storage/'.$this->path); } return Storage::disk($this->disk)->url($this->path); } public function formattedSize(): string { $bytes = max(0, (int) $this->size); if ($bytes >= 1048576) { return round($bytes / 1048576, 1).' MB'; } if ($bytes >= 1024) { return round($bytes / 1024, 1).' KB'; } return $bytes.' B'; } public function isImage(): bool { return str_starts_with((string) $this->mime_type, 'image/'); } }