getData(); } public function getData() { // Room, Audition, Draw Number, Name, School $ranker = App::make(RankAuditionEntries::class); $exportRows = [ 'Room,Audition,Draw Number,Student Name,School', ]; $rooms = Room::all(); foreach ($rooms as $room) { $auditions = $room->auditions()->orderBy('room_id')->orderBy('order_in_room')->get(); foreach ($auditions as $audition) { $entries = $audition->entries()->orderBy('draw_number')->get(); foreach ($entries as $entry) { $thisRow = $audition->room->name.','; $thisRow .= $audition->name.','; $thisRow .= $entry->draw_number.','; $thisRow .= $entry->student->full_name().','; $thisRow .= $entry->student->school->name.','; $exportRows[] = $thisRow; } } } //dd($exportRows); return $exportRows; } }