feat(desfile): refactor entry management to use row-based configuration and expand seat options
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user