feat(entry): simplify variant data handling in EntryResource by removing replaced variant logic
This commit is contained in:
@@ -12,14 +12,11 @@ class EntryResource extends JsonResource
|
|||||||
/** @return array<string, mixed> */
|
/** @return array<string, mixed> */
|
||||||
public function toArray(Request $request): array
|
public function toArray(Request $request): array
|
||||||
{
|
{
|
||||||
$variant = $this->variants->whereNull('replaced_by_variant_id')->sole();
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'title' => $this->nombre,
|
'title' => $this->nombre,
|
||||||
'description' => $this->descripcion,
|
'description' => $this->descripcion,
|
||||||
'event_date_ids' => $variant->selectedEventDates()->pluck('id')->values(),
|
'variants' => $this->variants->toArray(),
|
||||||
'stock' => $variant->inventory->real_stock,
|
|
||||||
'price' => $this->precio,
|
'price' => $this->precio,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user