diff --git a/app/Http/Controllers/NominationEnsembles/ScobdaNominationSeatingController.php b/app/Http/Controllers/NominationEnsembles/ScobdaNominationSeatingController.php index 5fb81f6..7b92c35 100644 --- a/app/Http/Controllers/NominationEnsembles/ScobdaNominationSeatingController.php +++ b/app/Http/Controllers/NominationEnsembles/ScobdaNominationSeatingController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\NominationEnsembles; use App\Http\Controllers\Controller; use App\Models\NominationEnsemble; use App\Models\NominationEnsembleEntry; +use App\Models\School; use App\Models\Student; use function redirect; @@ -13,13 +14,16 @@ class ScobdaNominationSeatingController extends Controller implements Nomination { public function index() { - $shirtReportType = request()->get('shirtReportType') || null; + $shirtReportType = request()->get('shirtReportType') ?? 'none'; $ensembles = NominationEnsemble::all(); $ensemble = null; $shirtCounts = ($shirtReportType == 'full') ? $this->totalShirtCount() : null; + $schoolShirtCounts = ($shirtReportType == 'by_school') ? $this->schoolShirtCount() : null; + $shirtSizes = Student::$shirtSizes; + $schools = School::all(); return view('nomination_ensembles.scobda.admin.seating.index', - compact('ensembles', 'ensemble', 'shirtReportType', 'shirtCounts')); + compact('ensembles', 'ensemble', 'shirtReportType', 'shirtCounts', 'schoolShirtCounts', 'shirtSizes', 'schools')); } protected function totalShirtCount() @@ -38,6 +42,26 @@ class ScobdaNominationSeatingController extends Controller implements Nomination return $shirtCounts; } + /** + * @return array an array of school ids, each containing and array where the key is a shirt size and the value is the count + */ + protected function schoolShirtCount(): array + { + $acceptedNominationEntries = NominationEnsembleEntry::where('data->accepted', true) + ->with('student.school') + ->get(); + $schoolShirtCounts = []; + foreach ($acceptedNominationEntries as $entry) { + if (! isset($schoolShirtCounts[$entry->student->school->id])) { + $schoolShirtCounts[$entry->student->school->id] = []; + } + $schoolShirtCounts[$entry->student->school->id][$entry->student->optional_data['shirt_size']] = + ($schoolShirtCounts[$entry->student->school->id][$entry->student->optional_data['shirt_size']] ?? 0) + 1; + } + + return $schoolShirtCounts; + } + public function show(NominationEnsemble $ensemble) { $ensembles = NominationEnsemble::all(); diff --git a/resources/views/nomination_ensembles/scobda/admin/seating/index.blade.php b/resources/views/nomination_ensembles/scobda/admin/seating/index.blade.php index 2aac1e5..06467b7 100644 --- a/resources/views/nomination_ensembles/scobda/admin/seating/index.blade.php +++ b/resources/views/nomination_ensembles/scobda/admin/seating/index.blade.php @@ -9,19 +9,26 @@
Shirts Needed