Scobda nomination ensembles #106

Merged
okorpheus merged 25 commits from scobda_first_year into master 2025-02-12 21:51:10 +00:00
4 changed files with 53 additions and 16 deletions
Showing only changes of commit a15cadc551 - Show all commits

View File

@ -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.'<br>Name: '.$student->full_name().'<br>Grade: '.$student->grade.'<br>School: '.$student->school->name;
AuditLogEntry::create([
'user' => auth()->user()->email,

View File

@ -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

View File

@ -7,7 +7,15 @@
<x-form.field name="first_name" label_text="First Name" type="text" value="{{ $student->first_name }}"/>
<x-form.field name="last_name" label_text="Last Name" type="text" value="{{ $student->last_name }}"/>
<x-form.field name="grade" label_text="Grade" type="number" class="mb-3" value="{{ $student->grade }}"/>
<x-form.footer submit-button-text="Save Changes" />
@if(auditionSetting('student_data_collect_shirt_size'))
<x-form.select name="shirt_size" colspan="2">
<x-slot:label>Shirt Size</x-slot:label>
@foreach($shirtSizes as $abbreviation => $name)
<option value="{{ $abbreviation }}" @if($abbreviation === ($student->optional_data['shirt_size'] ?? null) ) SELECTED @endif>{{ $name }}</option>
@endforeach
</x-form.select>
@endif
<x-form.footer submit-button-text="Save Changes"/>
</x-form.form>
</x-card.card>
</div>

View File

@ -24,17 +24,9 @@
@if(auditionSetting('student_data_collect_shirt_size'))
<x-form.select name="shirt_size" colspan="2">
<x-slot:label>Shirt Size</x-slot:label>
<option value="none"> </option>
<option value="YS">Youth S</option>
<option value="YM">Youth M</option>
<option value="YL">Youth L</option>
<option value="YXL">Youth XL</option>
<option value="S">S</option>
<option value="M">M</option>
<option value="L">L</option>
<option value="XL">XL</option>
<option value="2XL">2XL</option>
<option value="3XL">3XL</option>
@foreach($shirtSizes as $abbreviation => $name)
<option value="{{ $abbreviation }}">{{ $name }}</option>
@endforeach
</x-form.select>
@endif
@ -68,7 +60,7 @@
<x-table.td first>{{ $student->full_name(true) }}</x-table.td>
<x-table.td>{{ $student->grade }}</x-table.td>
@if(auditionSetting('student_data_collect_shirt_size'))
<x-table.th>sss</x-table.th>
<x-table.th>{{ $student->optional_data['shirt_size'] ?? '' }}</x-table.th>
@endif
<x-table.td class="hidden md:table-cell">{{ $student->entries_count }}</x-table.td>
<x-table.td for_button>