51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Actions\Reports;
|
|
|
|
use App\Actions\Tabulation\RankAuditionEntries;
|
|
use App\Models\Room;
|
|
use Illuminate\Support\Facades\App;
|
|
|
|
/**
|
|
* @codeCoverageIgnore
|
|
*/
|
|
// TODO figure out testing for ExportEntryData
|
|
class ExportEntryData
|
|
{
|
|
public function __construct()
|
|
{
|
|
}
|
|
|
|
public function __invoke(): void
|
|
{
|
|
$this->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;
|
|
}
|
|
}
|