From 06d722b7061d4148243f5fba63c0dc1bcd33701b Mon Sep 17 00:00:00 2001 From: Matt Young Date: Thu, 27 Jun 2024 22:29:02 -0500 Subject: [PATCH] Admin entries address TODO apply javascript to only show appropriate auditions for the students grade --- app/Models/Student.php | 12 ++++++--- .../views/admin/entries/create.blade.php | 26 +++++++++---------- .../student_audition_select_script.blade.php | 2 +- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/app/Models/Student.php b/app/Models/Student.php index 9d6badc..454cfb9 100644 --- a/app/Models/Student.php +++ b/app/Models/Student.php @@ -8,11 +8,12 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasManyThrough; - class Student extends Model { use HasFactory; + protected $guarded = []; + public function school(): BelongsTo { return $this->belongsTo(School::class); @@ -28,9 +29,12 @@ class Student extends Model 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; - return $this->first_name . ' ' . $this->last_name; + if ($last_name_first) { + return $this->last_name.', '.$this->first_name; + } + + return $this->first_name.' '.$this->last_name; } } diff --git a/resources/views/admin/entries/create.blade.php b/resources/views/admin/entries/create.blade.php index 486ce12..998fa00 100644 --- a/resources/views/admin/entries/create.blade.php +++ b/resources/views/admin/entries/create.blade.php @@ -2,21 +2,22 @@ Create Entry - + - + Student - @foreach ($students as $student) + + + - - @endforeach - - + Audition - @foreach ($auditions as $audition) - - - @endforeach + + @if(auditionSetting('advanceTo')) @@ -39,6 +40,5 @@ + @include('students.student_audition_select_script') - -{{--TODO apply javascript to only show appropriate auditions for the students grade--}} diff --git a/resources/views/students/student_audition_select_script.blade.php b/resources/views/students/student_audition_select_script.blade.php index 331a0b7..ca2fcde 100644 --- a/resources/views/students/student_audition_select_script.blade.php +++ b/resources/views/students/student_audition_select_script.blade.php @@ -5,7 +5,7 @@ students: [ @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 ], auditions: [