/** * Display the specified resource. * * @return \Illuminate\Http\Response */ public function showSales() { $events = Event::all(); $tickets = Ticket::all(); $eventInformation = []; foreach ($events as $event) { // pueden ser muchos eventos. Necesito informaciĆ³n para llenar la tabla $eventsDate = Presentation::where('event_id', '=', $event->id)->where('cancelled', '=', 0)->get(); foreach ($eventsDate as $eventDate) { $tickets = Ticket::where('presentation_id', '=', $eventDate->id)->get(); $onlineTickets = 0; $presentialTicket = 0; $subTotalOnline = 0; $subTotalPresential = 0; foreach ($tickets as $ticket) { if ($ticket->cancelled != 1) { if (empty($ticket->salesman_id)) { $onlineTickets = $onlineTickets + $ticket->quantity; $subTotalPresential = $subTotalPresential + $ticket->total_price; } else { $presentialTicket = $presentialTicket + $ticket->quantity; $subTotalOnline = $subTotalOnline + $ticket->total_price; } } } array_push($eventInformation, array($event->name, $eventDate->id, date("d/m/Y", $eventDate->starts_at), $onlineTickets, $subTotalPresential, $presentialTicket, $subTotalOnline, $subTotalPresential + $subTotalOnline)); } } // //return $eventInformation; return view('internal.admin.reports.sales', compact('eventInformation')); }