refactor(catalog): handle null validity time in CatalogItemDetailResource and update related tests

This commit is contained in:
2026-08-07 09:20:52 -03:00
parent 7b7efeb4cc
commit 14d53d1e0b
2 changed files with 29 additions and 2 deletions

View File

@@ -36,7 +36,9 @@ class CatalogItemDetailResource extends JsonResource
'max_units_per_user' => $this->max_units_per_user,
'has_tickets' => $this->has_tickets,
'validity_time_id' => $this->validity_time_id,
'validity_time' => ValidityTimeResource::make($this->validityTime),
'validity_time' => $this->validityTime === null
? null
: ValidityTimeResource::make($this->validityTime),
'attributes' => $this->attributesData(),
'stock_tecnico' => $this->when(
$selectedVariant === null,
@@ -101,7 +103,9 @@ class CatalogItemDetailResource extends JsonResource
'label' => $option->label,
'sort_order' => $option->sort_order,
'validity_time_id' => $option->validity_time_id,
'validity_time' => ValidityTimeResource::make($option->validityTime),
'validity_time' => $option->validityTime === null
? null
: ValidityTimeResource::make($option->validityTime),
'metadata' => $option->metadata,
])
->values(),