From 529542d1bab1c355063cf4f8a9458ed55d6447a7 Mon Sep 17 00:00:00 2001 From: Matt Young Date: Wed, 10 Jul 2024 01:03:09 -0500 Subject: [PATCH] Establish CalculateEntryScore interface and default implementation --- app/Actions/Tabulation/AllJudgesCount.php | 13 ++++++++ .../Tabulation/CalculateEntryScore.php | 4 ++- app/Http/Controllers/TestController.php | 31 ++++++------------- app/Providers/CalculateEntryScoreProvider.php | 26 ++++++++++++++++ bootstrap/providers.php | 1 + resources/views/test.blade.php | 14 ++------- 6 files changed, 55 insertions(+), 34 deletions(-) create mode 100644 app/Actions/Tabulation/AllJudgesCount.php create mode 100644 app/Providers/CalculateEntryScoreProvider.php diff --git a/app/Actions/Tabulation/AllJudgesCount.php b/app/Actions/Tabulation/AllJudgesCount.php new file mode 100644 index 0000000..6874d77 --- /dev/null +++ b/app/Actions/Tabulation/AllJudgesCount.php @@ -0,0 +1,13 @@ +'hornets']; + } +} diff --git a/app/Actions/Tabulation/CalculateEntryScore.php b/app/Actions/Tabulation/CalculateEntryScore.php index 90b8842..8a719a1 100644 --- a/app/Actions/Tabulation/CalculateEntryScore.php +++ b/app/Actions/Tabulation/CalculateEntryScore.php @@ -2,7 +2,9 @@ namespace App\Actions\Tabulation; +use App\Models\Entry; + interface CalculateEntryScore { - public function __invoke($mode, $entry): array; + public function calculate(string $mode, Entry $entry): array; } diff --git a/app/Http/Controllers/TestController.php b/app/Http/Controllers/TestController.php index 99fc429..2c336c3 100644 --- a/app/Http/Controllers/TestController.php +++ b/app/Http/Controllers/TestController.php @@ -2,32 +2,21 @@ namespace App\Http\Controllers; -use App\Services\AuditionService; -use App\Services\Invoice\InvoiceDataService; -use App\Services\TabulationService; -use Illuminate\Http\Request; -use Illuminate\Support\Facades\Session; +use App\Actions\Tabulation\CalculateEntryScore; +use App\Models\Entry; class TestController extends Controller { - protected $scoringGuideCacheService; - protected $tabulationService; - protected $invoiceService; - - public function __construct( - AuditionService $scoringGuideCacheService, - TabulationService $tabulationService, - InvoiceDataService $invoiceService - ) { - $this->scoringGuideCacheService = $scoringGuideCacheService; - $this->tabulationService = $tabulationService; - $this->invoiceService = $invoiceService; + protected CalculateEntryScore $bigCalc; + public function __construct(CalculateEntryScore $bigCalc) + { + $this->bigCalc = $bigCalc; } - public function flashTest(Request $request) + public function flashTest() { - $lines = $this->invoiceService->getLines(12); - $totalFees = $this->invoiceService->getGrandTotal(12); - return view('test', compact('lines','totalFees')); + $test = $this->bigCalc->calculate('seating', Entry::find(1127))['vinita']; + + return view('test', compact('test')); } } diff --git a/app/Providers/CalculateEntryScoreProvider.php b/app/Providers/CalculateEntryScoreProvider.php new file mode 100644 index 0000000..39bffcc --- /dev/null +++ b/app/Providers/CalculateEntryScoreProvider.php @@ -0,0 +1,26 @@ +app->singleton(CalculateEntryScore::class, AllJudgesCount::class); + } + + /** + * Bootstrap services. + */ + public function boot(): void + { + // + } +} diff --git a/bootstrap/providers.php b/bootstrap/providers.php index 9edefb0..fd4c1d5 100644 --- a/bootstrap/providers.php +++ b/bootstrap/providers.php @@ -2,6 +2,7 @@ return [ App\Providers\AppServiceProvider::class, + App\Providers\CalculateEntryScoreProvider::class, App\Providers\FortifyServiceProvider::class, App\Providers\InvoiceDataServiceProvider::class, ]; diff --git a/resources/views/test.blade.php b/resources/views/test.blade.php index bd114cc..2a17e73 100644 --- a/resources/views/test.blade.php +++ b/resources/views/test.blade.php @@ -8,18 +8,8 @@ Test Page @php - $entry = Entry::find(1127); - $judge = User::find(65); - $scoreArray = [ - 1 => 50, - 2 => 60, - 3 => 70, - 4 => 80, - 5 => 90, - ]; - enterScore($judge, $entry, $scoreArray); - dump($entry->audition->name); - @endphp + @endphp + Test value: {{ $test }}