getData(); } public function getData() { // Audition, Rank, Name, School, Score, Flags or Seat $ranker = App::make(RankAuditionEntries::class); $exportRows = [ 'Audition,Rank,Student Name,School,Grade,Score,Seat or Flag', ]; $events = Event::all(); foreach ($events as $event) { $auditions = $event->auditions; foreach ($auditions as $audition) { $entries = $ranker->rank('seating', $audition); foreach ($entries as $entry) { $thisRow = $audition->name.','; $thisRow .= $entry->raw_rank ?? ''; $thisRow .= ','; $thisRow .= $entry->student->full_name().','; $thisRow .= $entry->student->school->name.','; $thisRow .= $entry->student->grade.','; $thisRow .= $entry->score_totals[0] ?? ''; $thisRow .= ','; if ($entry->hasFlag('failed_prelim')) { $thisRow .= 'Failed Prelim'; } elseif ($entry->hasFlag('no_show')) { $thisRow .= 'No Show'; } elseif ($entry->hasFlag('declined')) { $thisRow .= 'Declined'; } else { $seat = Seat::where('entry_id', $entry->id)->first(); if ($seat) { $thisRow .= $seat->ensemble->name.' '.$seat->seat; } else { $thisRow .= ' '; } } $exportRows[] = $thisRow; } } } //dd($exportRows); return $exportRows; } }