refactor(tickets): reuse dynamic columns in exports

This commit is contained in:
2026-08-31 12:31:32 -03:00
parent fbfcb5cf63
commit 6a00d8d09c
4 changed files with 90 additions and 87 deletions

View File

@@ -11,15 +11,21 @@ use Illuminate\Support\Collection;
class AdminAppTicketPdfService
{
public function __construct(private readonly AdminAppTicketReportService $reportService) {}
public function __construct(
private readonly AdminAppTicketReportService $reportService,
private readonly AdminAppTicketColumnService $columnService,
) {}
/** @param Collection<int, Ticket> $tickets */
public function download(Tenant $tenant, Collection $tickets, string $timeZone): Response
{
$generatedAt = now();
$columns = $this->columnService->columns($tenant);
$rows = $this->reportService->rows($tickets);
$pdf = Pdf::loadView('pdf.adminapp.tickets', [
'tenant' => $tenant,
'tickets' => $this->reportService->rows($tickets),
'columns' => $columns,
'tickets' => $this->reportService->displayRows($rows, $columns, $timeZone),
'generatedAt' => $generatedAt,
'timeZone' => $timeZone,
])->setPaper('a3', 'landscape');