From cd420e02d8183534ccb65b8638ff607dfce8beef Mon Sep 17 00:00:00 2001 From: ncoronel Date: Mon, 29 Jun 2026 12:04:14 -0300 Subject: [PATCH] feat: create ProductService to handle product, variant, and attribute management operations --- app/Domains/Catalog/Services/ProductService.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 = [];