feat(variant): refactor selection values to expose options with labels; update related resources and tests for consistency
This commit is contained in:
@@ -46,7 +46,7 @@ class CatalogFeaturedItemResource extends JsonResource
|
||||
'stock_tecnico' => $catalogItem->inventory_policy === InventoryPolicy::Unlimited
|
||||
? null
|
||||
: $variant->inventory->availableStock(),
|
||||
'values' => $variant->selectionValues(),
|
||||
'values' => $variant->selectionOptions(),
|
||||
])
|
||||
->values(),
|
||||
];
|
||||
|
||||
@@ -104,9 +104,7 @@ class CatalogItemDetailResource extends JsonResource
|
||||
->map(fn ($eventDate, int $index): array => [
|
||||
'id' => $eventDate->id,
|
||||
'value' => (string) $eventDate->id,
|
||||
'label' => $eventDate->date->format('d/m/Y').' · '
|
||||
.substr($eventDate->time_start, 0, 5).' a '
|
||||
.substr($eventDate->time_end, 0, 5),
|
||||
'label' => $eventDate->date->format('d/m/Y'),
|
||||
'sort_order' => $index,
|
||||
'validity_time_id' => null,
|
||||
'validity_time' => null,
|
||||
@@ -156,7 +154,7 @@ class CatalogItemDetailResource extends JsonResource
|
||||
/** @return array<string, mixed> */
|
||||
private function variantData(Variant $variant): array
|
||||
{
|
||||
$values = $variant->selectionValues();
|
||||
$values = $variant->selectionOptions();
|
||||
$eventDates = $variant->selectedEventDates();
|
||||
|
||||
return [
|
||||
|
||||
@@ -45,7 +45,7 @@ class CatalogItemResource extends JsonResource
|
||||
'descripcion' => $variant->getDescription(),
|
||||
'precio' => number_format($variant->getPrice(), 2, '.', ''),
|
||||
'real_stock' => $variant->inventory?->real_stock,
|
||||
'values' => $variant->selectionValues(),
|
||||
'values' => $variant->selectionOptions(),
|
||||
'images' => $variant->attachments
|
||||
->map(fn ($attachment) => $attachment->getTemporaryUrl(1440))
|
||||
->values(),
|
||||
|
||||
@@ -42,7 +42,7 @@ class CatalogSearchItemResource extends JsonResource
|
||||
'stock_tecnico' => $this->inventory_policy === InventoryPolicy::Unlimited
|
||||
? null
|
||||
: $variant->inventory?->availableStock(),
|
||||
'values' => $variant->selectionValues(),
|
||||
'values' => $variant->selectionOptions(),
|
||||
])
|
||||
->values(),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user