$reservations * @return Collection> */ 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'] : '-'; } }