where('tenant_code', $tenant->codigo) ->where('user_id', $request->user()->getKey()) ->orderByDesc('id') ->get(); return TicketResource::collection($tickets)->response(); } public function downloadPdf(DownloadTicketsPdfRequest $request, Tenant $tenant): Response { $ticketIds = $request->validated('ticket_ids'); $tickets = Ticket::query() ->where('tenant_code', $tenant->codigo) ->where('user_id', $request->user()->getKey()) ->whereIn('id', $ticketIds) ->orderByDesc('id') ->get(); abort_if( $tickets->count() !== count($ticketIds), 404, 'Uno o más tickets no están disponibles.' ); return $this->ticketPdfService->download($tenant, $tickets); } }