refactor(catalog): return compact ticket selector options
This commit is contained in:
@@ -24,6 +24,10 @@ class CatalogFeaturedItemResource extends JsonResource
|
||||
return $this->columnWithImageData($catalogItem);
|
||||
}
|
||||
|
||||
if ($featuredGroup->product_layout === ProductLayout::TicketSelector) {
|
||||
return $this->ticketSelectorData($catalogItem);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'id' => $catalogItem->id,
|
||||
'type' => $catalogItem->type->value,
|
||||
@@ -48,13 +52,22 @@ class CatalogFeaturedItemResource extends JsonResource
|
||||
->values(),
|
||||
];
|
||||
|
||||
if ($featuredGroup->product_layout === ProductLayout::TicketSelector) {
|
||||
$data['image'] = $this->firstImageUrl($catalogItem);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function ticketSelectorData(CatalogItem $catalogItem): array
|
||||
{
|
||||
return [
|
||||
'id' => $catalogItem->id,
|
||||
'type' => $catalogItem->type->value,
|
||||
'nombre' => $catalogItem->nombre,
|
||||
'descripcion' => $catalogItem->descripcion,
|
||||
'precio' => $catalogItem->precio,
|
||||
'image' => $this->firstImageUrl($catalogItem),
|
||||
];
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function columnWithImageData(CatalogItem $catalogItem): array
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user