diff --git a/app/Domains/Catalog/Controllers/ProductController.php b/app/Domains/Catalog/Controllers/ProductController.php index 5a66881..9ae9aeb 100644 --- a/app/Domains/Catalog/Controllers/ProductController.php +++ b/app/Domains/Catalog/Controllers/ProductController.php @@ -24,6 +24,7 @@ class ProductController extends Controller 'attachments' => fn ($query) => $query->orderBy('attachments.id')->limit(1), 'brand', 'category', + 'attributes.options', ]) ->latest() ->paginateFromRequest() @@ -45,8 +46,7 @@ class ProductController extends Controller 'attachments', 'brand', 'category', - 'variants.definitions.attribute.options', - 'variants.attachments', + 'attributes.options', ])); } diff --git a/app/Domains/Catalog/Resources/ProductResource.php b/app/Domains/Catalog/Resources/ProductResource.php index 61220a4..313a9ac 100644 --- a/app/Domains/Catalog/Resources/ProductResource.php +++ b/app/Domains/Catalog/Resources/ProductResource.php @@ -31,7 +31,7 @@ class ProductResource extends JsonResource ->map(fn ($attachment) => $attachment->getTemporaryUrl(1440)) ->values() ), - 'variants' => ProductVariantResource::collection($this->whenLoaded('variants')), + 'attributes' => AttributeResource::collection($this->whenLoaded('attributes')), ]; } } diff --git a/app/Domains/Catalog/Services/ProductService.php b/app/Domains/Catalog/Services/ProductService.php index 9e393bb..df070a2 100644 --- a/app/Domains/Catalog/Services/ProductService.php +++ b/app/Domains/Catalog/Services/ProductService.php @@ -37,7 +37,7 @@ class ProductService $this->syncProductImages($product, $images); } - return $product->load(['attributes', 'attachments', 'brand', 'category']); + return $product->load(['attributes.options', 'attachments', 'brand', 'category']); }); } @@ -68,7 +68,7 @@ class ProductService $this->syncProductImages($product, $images); } - return $product->load(['attributes', 'attachments', 'brand', 'category']); + return $product->load(['attributes.options', 'attachments', 'brand', 'category']); }); }