feat(desfile): export entry reservations
This commit is contained in:
@@ -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'] : '-';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user