Admin entries address TODO apply javascript to only show appropriate auditions for the students grade

This commit is contained in:
Matt Young 2024-06-27 22:29:02 -05:00
parent dcee3b80fe
commit 06d722b706
3 changed files with 22 additions and 18 deletions

View File

@ -8,11 +8,12 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough; use Illuminate\Database\Eloquent\Relations\HasManyThrough;
class Student extends Model class Student extends Model
{ {
use HasFactory; use HasFactory;
protected $guarded = []; protected $guarded = [];
public function school(): BelongsTo public function school(): BelongsTo
{ {
return $this->belongsTo(School::class); return $this->belongsTo(School::class);
@ -28,9 +29,12 @@ class Student extends Model
return $this->hasMany(Entry::class); return $this->hasMany(Entry::class);
} }
public function full_name(Bool $last_name_first = false): String public function full_name(bool $last_name_first = false): string
{ {
if ($last_name_first) return $this->last_name . ', ' . $this->first_name; if ($last_name_first) {
return $this->first_name . ' ' . $this->last_name; return $this->last_name.', '.$this->first_name;
}
return $this->first_name.' '.$this->last_name;
} }
} }

View File

@ -2,21 +2,22 @@
<x-card.card class="mx-auto max-w-2xl"> <x-card.card class="mx-auto max-w-2xl">
<x-card.heading>Create Entry</x-card.heading> <x-card.heading>Create Entry</x-card.heading>
<x-form.form method="POST" action="/admin/entries"> <x-form.form method="POST" action="/admin/entries">
<x-form.body-grid columns="3"> <x-form.body-grid columns="3" x-data="studentAuditionFilter()">
<x-form.select name="student_id" colspan="2"> <x-form.select name="student_id" colspan="2" x-model="selectedStudentId" @change="filterAuditions">
<x-slot:label>Student</x-slot:label> <x-slot:label>Student</x-slot:label>
@foreach ($students as $student) <option value="" disabled selected>Select a student</option>
<template x-for="student in students" :key="student.id">
<option :value="student.id" x-text="`${student.name} - ${student.school} - Grade ${student.grade}`"></option>
</template>
</x-form.select>
<option value="{{ $student->id }}">{{ $student->full_name(true) }} - {{ $student->school->name }} (Grade {{ $student->grade }})</option> <x-form.select name="audition_id" colspan="1">
@endforeach
</x-form.select><x-form.select name="audition_id" colspan="1">
<x-slot:label>Audition</x-slot:label> <x-slot:label>Audition</x-slot:label>
@foreach ($auditions as $audition) <option value="" disabled selected>Select an audition</option>
<template x-for="audition in filteredAuditions" :key="audition.id">
<option value="{{ $audition->id }}"> {{ $audition->name }}</option> <option :value="audition.id" x-text="audition.name"></option>
@endforeach </template>
</x-form.select> </x-form.select>
@if(auditionSetting('advanceTo')) @if(auditionSetting('advanceTo'))
@ -39,6 +40,5 @@
</x-form.footer> </x-form.footer>
</x-form.form> </x-form.form>
</x-card.card> </x-card.card>
@include('students.student_audition_select_script')
</x-layout.app> </x-layout.app>
{{--TODO apply javascript to only show appropriate auditions for the students grade--}}

View File

@ -5,7 +5,7 @@
students: [ students: [
@foreach($students as $student) @foreach($students as $student)
{ id: {{ $student->id }}, name: '{{ $student->full_name() }}', grade: {{ $student->grade }} }, { id: {{ $student->id }}, name: '{{ $student->full_name(true) }}', grade: {{ $student->grade }}, school: '{{ $student->school->name }}' },
@endforeach @endforeach
], ],
auditions: [ auditions: [