feat(desfile): export entry reservations

This commit is contained in:
2026-09-24 10:14:56 -03:00
parent d8d8354070
commit 0e870776c4
9 changed files with 375 additions and 7 deletions

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Domains\Ticketing\Desfile\Services;
use App\Domains\Ticketing\Desfile\Models\EntryReservation;
use Illuminate\Support\Collection;
class EntryReservationReportService
{
/**
* @param Collection<int, EntryReservation> $reservations
* @return Collection<int, array<string, mixed>>
*/
public function rows(Collection $reservations): Collection
{
return $reservations->values()->map(function (EntryReservation $reservation): array {
$selection = $reservation->variant->selectionOptions();
return [
'tipo' => $this->selectionLabel($selection->get('tipo')),
'sector' => $this->selectionLabel($selection->get('sector')),
'fila' => $this->selectionLabel($selection->get('fila')),
'asiento' => $this->selectionLabel($selection->get('asiento')),
'ticket_id' => $reservation->ticket_id,
'fecha_reserva' => $reservation->fecha_reserva,
'importe' => $reservation->importe,
'pago' => $reservation->tipo_pago->label(),
];
});
}
private function selectionLabel(mixed $selection): string
{
if (! is_array($selection)) {
return '-';
}
if (array_is_list($selection)) {
return collect($selection)->pluck('label')->filter()->implode(', ') ?: '-';
}
return isset($selection['label']) ? (string) $selection['label'] : '-';
}
}