diff --git a/app/Http/Controllers/Admin/ScoringGuideController.php b/app/Http/Controllers/Admin/ScoringGuideController.php new file mode 100644 index 0000000..b60d24c --- /dev/null +++ b/app/Http/Controllers/Admin/ScoringGuideController.php @@ -0,0 +1,89 @@ +is_admin) abort(403); + $guides = ScoringGuide::orderBy('name')->get(); + return view('admin.scoring.index',['guides'=>$guides]); + } + + public function store() + { + if (! Auth::user()->is_admin) abort(403); + + request()->validate([ + 'name' => ['required','unique:scoring_guides'] + ]); + + $guide = ScoringGuide::create([ + 'name' => request('name') + ]); + + return redirect('/admin/scoring'); + } + + public function edit(ScoringGuide $guide) + { + if (! Auth::user()->is_admin) abort(403); + $subscores = SubscoreDefinition::where('scoring_guide_id',$guide->id)->orderBy('display_order')->get(); + return view('admin.scoring.edit',['guide'=>$guide,'subscores'=>$subscores]); + } + + public function update(ScoringGuide $guide) + { + if (! Auth::user()->is_admin) abort(403); + request()->validate([ + 'name' => ['required','unique:scoring_guides'] + ]); + + $guide->update([ + 'name' => request('name') + ]); + return redirect('/admin/scoring/guides/' . $guide->id . '/edit' )->with('success','Scoring guide updated'); + } + + public function subscore_store(Request $request, ScoringGuide $guide) + { + if (! Auth::user()->is_admin) abort(403); + if (!$guide->exists()) abort(409); + $validateData = request()->validate([ + 'name' => ['required'], + 'max_score' => ['required','integer'], + 'weight'=>['required','integer'], + 'display_order'=>['required','integer'], + 'tiebreak_order'=>['required','integer'], + 'for_seating'=>['nullable','boolean'], + 'for_advance'=>['nullable','boolean'], + ]); + + $for_seating = $request->has('for_seating') ? (bool) $request->input('for_seating') : false; + $for_advance = $request->has('for_advance') ? (bool) $request->input('for_advance') : false; + + $subscore = SubscoreDefinition::create([ + 'scoring_guide_id' => $guide->id, + 'name' => $validateData['name'], + 'max_score' => $validateData['max_score'], + 'weight' => $validateData['weight'], + 'display_order' => $validateData['display_order'], + 'tiebreak_order' => $validateData['tiebreak_order'], + 'for_seating' => $for_seating, + 'for_advance' => $for_advance, + ]); + + return redirect('/admin/scoring/guides/' . $guide->id . '/edit' )->with('success','Subscore added'); + } +} diff --git a/app/Models/ScoringGuide.php b/app/Models/ScoringGuide.php new file mode 100644 index 0000000..97c2b7f --- /dev/null +++ b/app/Models/ScoringGuide.php @@ -0,0 +1,12 @@ + + */ +class ScoringGuideFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/database/factories/SubscoreDefinitionFactory.php b/database/factories/SubscoreDefinitionFactory.php new file mode 100644 index 0000000..2ce384e --- /dev/null +++ b/database/factories/SubscoreDefinitionFactory.php @@ -0,0 +1,23 @@ + + */ +class SubscoreDefinitionFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/database/migrations/2024_06_01_163911_create_site_settings_table.php b/database/migrations/2024_06_01_163911_create_site_settings_table.php index 01149e7..1bec36f 100644 --- a/database/migrations/2024_06_01_163911_create_site_settings_table.php +++ b/database/migrations/2024_06_01_163911_create_site_settings_table.php @@ -14,7 +14,7 @@ return new class extends Migration Schema::create('site_settings', function (Blueprint $table) { $table->id(); $table->string('setting_key')->unique(); - $table->text('setting_value'); + $table->text('setting_value')->nullable(); }); } diff --git a/database/migrations/2024_06_03_165156_create_scoring_guides_table.php b/database/migrations/2024_06_03_165156_create_scoring_guides_table.php new file mode 100644 index 0000000..62c8313 --- /dev/null +++ b/database/migrations/2024_06_03_165156_create_scoring_guides_table.php @@ -0,0 +1,28 @@ +id(); + $table->string('name')->unique(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('scoring_guides'); + } +}; diff --git a/database/migrations/2024_06_03_165227_create_subscore_definitions_table.php b/database/migrations/2024_06_03_165227_create_subscore_definitions_table.php new file mode 100644 index 0000000..451c0b6 --- /dev/null +++ b/database/migrations/2024_06_03_165227_create_subscore_definitions_table.php @@ -0,0 +1,36 @@ +id(); + $table->foreignIdFor(ScoringGuide::class); + $table->string('name'); + $table->integer('max_score'); + $table->integer('weight'); + $table->integer('display_order'); + $table->integer('tiebreak_order'); + $table->boolean('for_seating')->default(true); + $table->boolean('for_advance')->default(true); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('subscore_definitions'); + } +}; diff --git a/database/seeders/ScoringGuideSeeder.php b/database/seeders/ScoringGuideSeeder.php new file mode 100644 index 0000000..d952a62 --- /dev/null +++ b/database/seeders/ScoringGuideSeeder.php @@ -0,0 +1,17 @@ + + Scoring Rules + +{{-- MAIN CARD--}} + + + Click here to rename + Scoring Guide: {{ $guide->name }} + +
+ + Subscores + + + + Name + Max Score + Weight + Display Order + Tiebreak Order + For Seating + @if(Settings::advanceTo()) + For {{ Settings::advanceTo() }} + @endif + + + + + @foreach ($subscores as $subscore) + + {{ $subscore->name }} + {{ $subscore->max_score }} + {{ $subscore->weight }} + {{ $subscore->display_order }} + {{ $subscore->tiebreak_order }} + {{ $subscore->for_seating ? 'Yes' : 'No' }} + @if(Settings::advanceTo()) + {{ $subscore->for_advance ? 'Yes' : 'No' }} + @endif + +{{-- This came from AI, consider--}} +{{-- --}} +{{-- Save--}} +{{-- Delete--}} +{{-- Rename--}} +{{-- --}} +   + + + + @endforeach + + + Add Subscore + + + + + + + + @if(Settings::advanceTo()) + + @endif + Save + + + + +
+
+ + +{{-- RENAME CARD--}} + + Rename + + + + + +
+ @php(dump($guide)) +
+ diff --git a/resources/views/admin/scoring/index.blade.php b/resources/views/admin/scoring/index.blade.php new file mode 100644 index 0000000..59c42e6 --- /dev/null +++ b/resources/views/admin/scoring/index.blade.php @@ -0,0 +1,41 @@ + + Scoring Rules +
+ + + Scoring Guides + Each audition will be assigned a scoring guide. + + + + + Name + + + + + + @foreach($guides as $guide) + + {{ $guide->name }} + Edit +{{-- TODO add a link to delete if the guide is not in use--}} + + @endforeach + + + + + + + + + Create + + + + + + +
+
diff --git a/resources/views/components/card/list/row.blade.php b/resources/views/components/card/list/row.blade.php index 1512df3..fbab52a 100644 --- a/resources/views/components/card/list/row.blade.php +++ b/resources/views/components/card/list/row.blade.php @@ -1,5 +1,5 @@ @props(['right_link_button_type' => 'a']) {{-- Use if the link to the right needs to be a button --}} -
  • +
  • merge(['class'=>'flex items-center justify-between gap-x-6 px-4 py-5 sm:px-6']) }}>
    {{ $slot }}
    diff --git a/resources/views/components/form/toggle-checkbox.blade.php b/resources/views/components/form/toggle-checkbox.blade.php new file mode 100644 index 0000000..531c054 --- /dev/null +++ b/resources/views/components/form/toggle-checkbox.blade.php @@ -0,0 +1,11 @@ +@props(['name', 'checked' => false]) +
    + + @error($name) +

    {{ $message }}

    + @enderror +
    diff --git a/resources/views/components/layout/app.blade.php b/resources/views/components/layout/app.blade.php index cced3c0..e19fb26 100644 --- a/resources/views/components/layout/app.blade.php +++ b/resources/views/components/layout/app.blade.php @@ -30,7 +30,7 @@ -
    +
    @foreach(getMessages() as $message) diff --git a/resources/views/components/layout/navbar-admin.blade.php b/resources/views/components/layout/navbar-admin.blade.php index 94b3fa7..5605808 100644 --- a/resources/views/components/layout/navbar-admin.blade.php +++ b/resources/views/components/layout/navbar-admin.blade.php @@ -12,17 +12,31 @@
    Your Company
    -