feat(desfile): refactor entry management to use row-based configuration and expand seat options

This commit is contained in:
2026-08-14 13:32:02 -03:00
parent 4be94275f1
commit de8da72354
8 changed files with 298 additions and 188 deletions

View File

@@ -16,18 +16,35 @@ class EntryResource extends JsonResource
return [
'id' => $this->id,
'variants' => $this->variants->map(function ($variant): array {
$values = $variant->selectionValues();
'rows' => $this->variants
->map(function ($variant): array {
$values = $variant->selectionValues();
return [
'id' => $variant->id,
'type' => $values->get('tipo'),
'sector' => $values->get('sector'),
'row' => $values->get('fila'),
'seat' => $values->get('asiento'),
'price' => number_format($variant->getPrice(), 2, '.', ''),
];
})->values(),
return [
'type' => $values->get('tipo'),
'sector' => $values->get('sector'),
'row' => $values->get('fila'),
'seat' => (int) $values->get('asiento'),
'price' => $variant->getPrice(),
];
})
->groupBy(fn (array $variant): string => implode('|', [
mb_strtolower(trim((string) $variant['type'])),
mb_strtolower(trim((string) $variant['sector'])),
mb_strtolower(trim((string) $variant['row'])),
]))
->map(function ($variants): array {
$first = $variants->first();
return [
'type' => $first['type'],
'sector' => $first['sector'],
'row' => $first['row'],
'max_seat' => $variants->max('seat'),
'price' => number_format($first['price'], 2, '.', ''),
];
})
->values(),
'image' => $image === null ? null : [
'key' => $image->key,
'filename' => $image->filename,