diff --git a/app/Http/Controllers/StudentController.php b/app/Http/Controllers/StudentController.php
index 32ff1e9..52628ae 100644
--- a/app/Http/Controllers/StudentController.php
+++ b/app/Http/Controllers/StudentController.php
@@ -25,7 +25,10 @@ class StudentController extends Controller
$students = Auth::user()->students()->withCount('entries')->get();
$auditions = Audition::all();
- return view('students.index', ['students' => $students, 'auditions' => $auditions]);
+ $shirtSizes = Student::$shirtSizes;
+
+ return view('students.index',
+ ['students' => $students, 'auditions' => $auditions, 'shirtSizes' => $shirtSizes]);
}
/**
@@ -51,7 +54,14 @@ class StudentController extends Controller
new UniqueFullNameAtSchool(request('first_name'), request('last_name'), Auth::user()->school_id),
],
'grade' => ['required', 'integer'],
- 'shirt_size' => ['nullable'],
+ 'shirt_size' => [
+ 'nullable',
+ function ($attribute, $value, $fail) {
+ if (! array_key_exists($value, Student::$shirtSizes)) {
+ $fail("The selected $attribute is invalid.");
+ }
+ },
+ ],
]);
$student = Student::create([
@@ -94,7 +104,9 @@ class StudentController extends Controller
abort(403);
}
- return view('students.edit', ['student' => $student]);
+ $shirtSizes = Student::$shirtSizes;
+
+ return view('students.edit', ['student' => $student, 'shirtSizes' => $shirtSizes]);
}
/**
@@ -110,6 +122,14 @@ class StudentController extends Controller
'first_name' => ['required'],
'last_name' => ['required'],
'grade' => ['required', 'integer'],
+ 'shirt_size' => [
+ 'nullable',
+ function ($attribute, $value, $fail) {
+ if (! array_key_exists($value, Student::$shirtSizes)) {
+ $fail("The selected $attribute is invalid.");
+ }
+ },
+ ],
]);
if (Student::where('first_name', request('first_name'))
@@ -126,6 +146,9 @@ class StudentController extends Controller
'last_name' => request('last_name'),
'grade' => request('grade'),
]);
+
+ $student->update(['optional_data->shirt_size' => $request['shirt_size']]);
+
$message = 'Updated student #'.$student->id.'
Name: '.$student->full_name().'
Grade: '.$student->grade.'
School: '.$student->school->name;
AuditLogEntry::create([
'user' => auth()->user()->email,
diff --git a/app/Models/Student.php b/app/Models/Student.php
index 67ae150..d1e1777 100644
--- a/app/Models/Student.php
+++ b/app/Models/Student.php
@@ -12,6 +12,20 @@ class Student extends Model
{
use HasFactory;
+ public static $shirtSizes = [
+ 'none' => '---',
+ 'YS' => 'Youth Small',
+ 'YM' => 'Youth Medium',
+ 'YL' => 'Youth Large',
+ 'YXL' => 'Youth Extra Large',
+ 'S' => 'Small',
+ 'M' => 'Medium',
+ 'L' => 'Large',
+ 'XL' => 'Extra Large',
+ '2XL' => '2XL',
+ '3XL' => '3XL',
+ ];
+
protected $guarded = [];
protected function casts(): array
diff --git a/resources/views/students/edit.blade.php b/resources/views/students/edit.blade.php
index 747982a..70a6b5a 100644
--- a/resources/views/students/edit.blade.php
+++ b/resources/views/students/edit.blade.php
@@ -7,7 +7,15 @@
-
+ @if(auditionSetting('student_data_collect_shirt_size'))
+
+ Shirt Size
+ @foreach($shirtSizes as $abbreviation => $name)
+
+ @endforeach
+
+ @endif
+
diff --git a/resources/views/students/index.blade.php b/resources/views/students/index.blade.php
index a2b1968..b4c577a 100644
--- a/resources/views/students/index.blade.php
+++ b/resources/views/students/index.blade.php
@@ -24,17 +24,9 @@
@if(auditionSetting('student_data_collect_shirt_size'))
Shirt Size
-
-
-
-
-
-
-
-
-
-
-
+ @foreach($shirtSizes as $abbreviation => $name)
+
+ @endforeach
@endif
@@ -68,7 +60,7 @@
{{ $student->full_name(true) }}
{{ $student->grade }}
@if(auditionSetting('student_data_collect_shirt_size'))
- sss
+ {{ $student->optional_data['shirt_size'] ?? '' }}
@endif
{{ $student->entries_count }}