T-shirt by school for SCOBDA - deal with school with no entries

This commit is contained in:
Matt Young 2025-03-06 20:34:54 -06:00
parent 5d93ba0799
commit 65b8c8bd81
1 changed files with 11 additions and 6 deletions

View File

@ -23,7 +23,8 @@ class ScobdaNominationSeatingController extends Controller implements Nomination
$schools = School::all();
return view('nomination_ensembles.scobda.admin.seating.index',
compact('ensembles', 'ensemble', 'shirtReportType', 'shirtCounts', 'schoolShirtCounts', 'shirtSizes', 'schools'));
compact('ensembles', 'ensemble', 'shirtReportType', 'shirtCounts', 'schoolShirtCounts', 'shirtSizes',
'schools'));
}
protected function totalShirtCount()
@ -52,11 +53,13 @@ class ScobdaNominationSeatingController extends Controller implements Nomination
->get();
$schoolShirtCounts = [];
foreach ($acceptedNominationEntries as $entry) {
if (! isset($schoolShirtCounts[$entry->student->school->id])) {
$schoolShirtCounts[$entry->student->school->id] = [];
$shirtSize = $entry->student->optional_data['shirt_size'] ?? 'none';
$schoolId = $entry->student->school->id;
if (! isset($schoolShirtCounts[$schoolId])) {
$schoolShirtCounts[$schoolId] = [];
}
$schoolShirtCounts[$entry->student->school->id][$entry->student->optional_data['shirt_size']] =
($schoolShirtCounts[$entry->student->school->id][$entry->student->optional_data['shirt_size']] ?? 0) + 1;
$schoolShirtCounts[$schoolId][$shirtSize] =
($schoolShirtCounts[$schoolId][$shirtSize] ?? 0) + 1;
}
return $schoolShirtCounts;
@ -64,6 +67,8 @@ class ScobdaNominationSeatingController extends Controller implements Nomination
public function show(NominationEnsemble $ensemble)
{
$shirtReportType = request()->get('shirtReportType') ?? 'none';
$ensembles = NominationEnsemble::all();
$acceptedNominations = NominationEnsembleEntry::where('nomination_ensemble_id', $ensemble->id)
->where('data->accepted', true)
@ -74,7 +79,7 @@ class ScobdaNominationSeatingController extends Controller implements Nomination
});
return view('nomination_ensembles.scobda.admin.seating.index',
compact('ensembles', 'ensemble', 'acceptedNominations'));
compact('ensembles', 'ensemble', 'acceptedNominations', 'shirtReportType'));
}