From d4c90da8077252dade5c6bb8fa8c7198ed0d27b2 Mon Sep 17 00:00:00 2001 From: "Joseph.Rawlings" Date: Sun, 30 Nov 2025 08:20:51 -0500 Subject: [PATCH] feat: add storage_url helper function and update image URL retrieval to use public disk --- app/Classes/helpers.php | 17 +++++++++++++ app/Helpers/StorageHelper.php | 24 +++++++++++++++++++ app/Livewire/Products/Index.php | 2 +- app/Livewire/Products/Show.php | 2 +- .../Others/SocialBase/Models/UserProfile.php | 4 ++-- .../views/profile/settings.blade.php | 4 ++-- 6 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 app/Helpers/StorageHelper.php diff --git a/app/Classes/helpers.php b/app/Classes/helpers.php index decd3b85e..655646d31 100644 --- a/app/Classes/helpers.php +++ b/app/Classes/helpers.php @@ -31,3 +31,20 @@ if (!function_exists('hook')) { return \App\Helpers\EventHelper::renderEvent($event); } } + +if (!function_exists('storage_url')) { + /** + * Get the URL for a file stored on the public disk + * + * @param string|null $path + * @return string|null + */ + function storage_url(?string $path): ?string + { + if (!$path) { + return null; + } + + return \Illuminate\Support\Facades\Storage::disk('public')->url($path); + } +} \ No newline at end of file diff --git a/app/Helpers/StorageHelper.php b/app/Helpers/StorageHelper.php new file mode 100644 index 000000000..9d2fe3447 --- /dev/null +++ b/app/Helpers/StorageHelper.php @@ -0,0 +1,24 @@ +url($path); + } +} + diff --git a/app/Livewire/Products/Index.php b/app/Livewire/Products/Index.php index 58acf58d8..7cb056fb4 100644 --- a/app/Livewire/Products/Index.php +++ b/app/Livewire/Products/Index.php @@ -38,7 +38,7 @@ class Index extends Component { return view('products.index')->layoutData([ 'title' => $this->category->name, - 'image' => $this->category->image ? Storage::url($this->category->image) : null, + 'image' => $this->category->image ? Storage::disk('public')->url($this->category->image) : null, ]); } } diff --git a/app/Livewire/Products/Show.php b/app/Livewire/Products/Show.php index 70051e53f..b46d6061d 100644 --- a/app/Livewire/Products/Show.php +++ b/app/Livewire/Products/Show.php @@ -21,7 +21,7 @@ class Show extends Component { return view('products.show')->layoutData([ 'title' => $this->product->name, - 'image' => $this->product->image ? Storage::url($this->product->image) : null, + 'image' => $this->product->image ? Storage::disk('public')->url($this->product->image) : null, ]); } } diff --git a/extensions/Others/SocialBase/Models/UserProfile.php b/extensions/Others/SocialBase/Models/UserProfile.php index 50e4e29c1..79c9e0fcb 100644 --- a/extensions/Others/SocialBase/Models/UserProfile.php +++ b/extensions/Others/SocialBase/Models/UserProfile.php @@ -117,7 +117,7 @@ class UserProfile extends Model public function getAvatarUrlAttribute(): ?string { if ($this->avatar_path) { - return Storage::url($this->avatar_path); + return Storage::disk('public')->url($this->avatar_path); } // Return default avatar or gravatar @@ -135,7 +135,7 @@ class UserProfile extends Model public function getBannerUrlAttribute(): ?string { if ($this->banner_path) { - return Storage::url($this->banner_path); + return Storage::disk('public')->url($this->banner_path); } return null; diff --git a/extensions/Others/SocialBase/resources/views/profile/settings.blade.php b/extensions/Others/SocialBase/resources/views/profile/settings.blade.php index 5918eca17..f99f7b041 100644 --- a/extensions/Others/SocialBase/resources/views/profile/settings.blade.php +++ b/extensions/Others/SocialBase/resources/views/profile/settings.blade.php @@ -22,7 +22,7 @@
@if($profile->avatar_path) - Current Avatar @else @@ -69,7 +69,7 @@
@if($profile->banner_path)
- Current Banner