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(); if ($tickets->count() !== count($ticketIds)) { throw new TicketNotAvailableException(__('api.ticket.not_available')); } return $this->ticketPdfService->download($tenant, $tickets); } }