diff --git a/app/Domains/Catalog/Services/ProductService.php b/app/Domains/Catalog/Services/ProductService.php index e1905ca..74fe24d 100644 --- a/app/Domains/Catalog/Services/ProductService.php +++ b/app/Domains/Catalog/Services/ProductService.php @@ -166,8 +166,12 @@ class ProductService */ protected function syncImages(ProductVariant $variant, array $images): void { - // Detach any existing attachments before replacing them + // Detach pivot record and delete attachment from S3 and database + $existing = $variant->attachments()->get(); $variant->attachments()->detach(); + foreach ($existing as $attachment) { + $this->attachmentService->delete($attachment); + } $attachmentIds = [];