diff --git a/app/Services/EquipmentPhotoService.php b/app/Services/EquipmentPhotoService.php index 8867254b..c4c3c876 100644 --- a/app/Services/EquipmentPhotoService.php +++ b/app/Services/EquipmentPhotoService.php @@ -23,7 +23,8 @@ class EquipmentPhotoService private const QUALITY_STEP = 5; public function __construct( - private readonly GoogleCloudService $googleCloudService + private readonly GoogleCloudService $googleCloudService, + private readonly GoogleCloudStorageService $googleCloudStorageService, ) {} /** @@ -207,12 +208,11 @@ public function deletePhoto(Equipment $equipment, int $fileId): bool public function getPhotoUrls(Equipment $equipment): array { $photos = $equipment->photos()->get(); - $bucket = config('services.google.storage_bucket'); - return $photos->map(function ($photo) use ($bucket) { + return $photos->map(function ($photo) { $url = null; - if ($photo->gcs_object_name && $bucket) { - $url = "https://storage.googleapis.com/{$bucket}/{$photo->gcs_object_name}"; + if ($photo->gcs_object_name) { + $url = $this->googleCloudStorageService->getSignedUrl($photo->gcs_object_name, 120); } return [ diff --git a/resources/views/equipment/partials/tabs/basic-info.blade.php b/resources/views/equipment/partials/tabs/basic-info.blade.php index f32bc5cf..f0025d0f 100644 --- a/resources/views/equipment/partials/tabs/basic-info.blade.php +++ b/resources/views/equipment/partials/tabs/basic-info.blade.php @@ -91,9 +91,8 @@
@foreach($equipment->photos as $photo) @php - $bucket = config('services.google.storage_bucket'); - $url = $photo->gcs_object_name && $bucket - ? "https://storage.googleapis.com/{$bucket}/{$photo->gcs_object_name}" + $url = $photo->gcs_object_name + ? app(\App\Services\GoogleCloudStorageService::class)->getSignedUrl($photo->gcs_object_name, 120) : null; @endphp @if($url)