Scobda nomination ensembles #106
|
|
@ -25,7 +25,10 @@ class StudentController extends Controller
|
||||||
$students = Auth::user()->students()->withCount('entries')->get();
|
$students = Auth::user()->students()->withCount('entries')->get();
|
||||||
$auditions = Audition::all();
|
$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),
|
new UniqueFullNameAtSchool(request('first_name'), request('last_name'), Auth::user()->school_id),
|
||||||
],
|
],
|
||||||
'grade' => ['required', 'integer'],
|
'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([
|
$student = Student::create([
|
||||||
|
|
@ -94,7 +104,9 @@ class StudentController extends Controller
|
||||||
abort(403);
|
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'],
|
'first_name' => ['required'],
|
||||||
'last_name' => ['required'],
|
'last_name' => ['required'],
|
||||||
'grade' => ['required', 'integer'],
|
'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'))
|
if (Student::where('first_name', request('first_name'))
|
||||||
|
|
@ -126,6 +146,9 @@ class StudentController extends Controller
|
||||||
'last_name' => request('last_name'),
|
'last_name' => request('last_name'),
|
||||||
'grade' => request('grade'),
|
'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;
|
$message = 'Updated student #'.$student->id.'<br>Name: '.$student->full_name().'<br>Grade: '.$student->grade.'<br>School: '.$student->school->name;
|
||||||
AuditLogEntry::create([
|
AuditLogEntry::create([
|
||||||
'user' => auth()->user()->email,
|
'user' => auth()->user()->email,
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,20 @@ class Student extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
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 $guarded = [];
|
||||||
|
|
||||||
protected function casts(): array
|
protected function casts(): array
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,15 @@
|
||||||
<x-form.field name="first_name" label_text="First Name" type="text" value="{{ $student->first_name }}"/>
|
<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="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.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-form.form>
|
||||||
</x-card.card>
|
</x-card.card>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -24,17 +24,9 @@
|
||||||
@if(auditionSetting('student_data_collect_shirt_size'))
|
@if(auditionSetting('student_data_collect_shirt_size'))
|
||||||
<x-form.select name="shirt_size" colspan="2">
|
<x-form.select name="shirt_size" colspan="2">
|
||||||
<x-slot:label>Shirt Size</x-slot:label>
|
<x-slot:label>Shirt Size</x-slot:label>
|
||||||
<option value="none"> </option>
|
@foreach($shirtSizes as $abbreviation => $name)
|
||||||
<option value="YS">Youth S</option>
|
<option value="{{ $abbreviation }}">{{ $name }}</option>
|
||||||
<option value="YM">Youth M</option>
|
@endforeach
|
||||||
<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>
|
|
||||||
</x-form.select>
|
</x-form.select>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
|
@ -68,7 +60,7 @@
|
||||||
<x-table.td first>{{ $student->full_name(true) }}</x-table.td>
|
<x-table.td first>{{ $student->full_name(true) }}</x-table.td>
|
||||||
<x-table.td>{{ $student->grade }}</x-table.td>
|
<x-table.td>{{ $student->grade }}</x-table.td>
|
||||||
@if(auditionSetting('student_data_collect_shirt_size'))
|
@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
|
@endif
|
||||||
<x-table.td class="hidden md:table-cell">{{ $student->entries_count }}</x-table.td>
|
<x-table.td class="hidden md:table-cell">{{ $student->entries_count }}</x-table.td>
|
||||||
<x-table.td for_button>
|
<x-table.td for_button>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue