From 4084c97d926412207cc3830b21a079d791cbd8c8 Mon Sep 17 00:00:00 2001 From: al-saloul Date: Thu, 11 Dec 2025 12:15:02 +0300 Subject: [PATCH] git commit -m "feat: Add disk support, cursor pointer, and remove empty text - Add disk() method for Storage integration - Add visibility() method for private files with temporary URLs - Change cursor from zoom-in to pointer - Remove empty text display when no images - Support Filament v3.x and v4.x" --- .../views/columns/image-gallery.blade.php | 8 +-- src/Tables/Columns/ImageGalleryColumn.php | 71 ++++++++++++++++--- 2 files changed, 65 insertions(+), 14 deletions(-) diff --git a/resources/views/columns/image-gallery.blade.php b/resources/views/columns/image-gallery.blade.php index 3b65c5d..f7122ab 100644 --- a/resources/views/columns/image-gallery.blade.php +++ b/resources/views/columns/image-gallery.blade.php @@ -51,17 +51,15 @@ data-viewer-gallery wire:ignore.self > - @forelse($visibleUrls as $src) + @foreach($visibleUrls as $src) image - @empty - {{ $getEmptyText() }} - @endforelse + @endforeach @if($shouldShowRemainingText() && $remaining > 0) thumbWidth = $width; @@ -165,6 +170,30 @@ class ImageGalleryColumn extends Column return $this->evaluate($this->emptyText); } + public function disk(string | Closure | null $disk): static + { + $this->disk = $disk; + + return $this; + } + + public function getDisk(): ?string + { + return $this->evaluate($this->disk); + } + + public function visibility(string | Closure $visibility): static + { + $this->visibility = $visibility; + + return $this; + } + + public function getVisibility(): string + { + return $this->evaluate($this->visibility); + } + /** * Get normalized image URLs from state */ @@ -176,18 +205,42 @@ class ImageGalleryColumn extends Column return []; } - return collect($state)->map(function ($item) { + $disk = $this->getDisk(); + $visibility = $this->getVisibility(); + + return collect($state)->map(function ($item) use ($disk, $visibility) { + $path = null; + if (is_string($item)) { - return $item; - } - if (is_array($item)) { - return $item['image'] ?? $item['url'] ?? null; - } - if (is_object($item)) { - return $item->image ?? $item->url ?? null; + $path = $item; + } elseif (is_array($item)) { + $path = $item['image'] ?? $item['url'] ?? $item['path'] ?? null; + } elseif (is_object($item)) { + $path = $item->image ?? $item->url ?? $item->path ?? null; } - return null; + if (empty($path)) { + return null; + } + + // If it's already a full URL, return as-is + if (filter_var($path, FILTER_VALIDATE_URL)) { + return $path; + } + + // If disk is specified, generate URL from storage + if ($disk) { + $storage = Storage::disk($disk); + + if ($visibility === 'private') { + return $storage->temporaryUrl($path, now()->addMinutes(5)); + } + + return $storage->url($path); + } + + // Default: return path as-is (might be relative URL) + return $path; })->filter()->values()->toArray(); } }