From 74b9d3f141aa73de4a6b7307d490eae28c102ad6 Mon Sep 17 00:00:00 2001 From: Matt Young Date: Wed, 9 Jul 2025 16:10:56 -0500 Subject: [PATCH] add test for admin DrawController. Work on deprecating DrawService --- app/Http/Controllers/Admin/DrawController.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/Admin/DrawController.php b/app/Http/Controllers/Admin/DrawController.php index b97a6eb..e46cfea 100644 --- a/app/Http/Controllers/Admin/DrawController.php +++ b/app/Http/Controllers/Admin/DrawController.php @@ -2,13 +2,13 @@ namespace App\Http\Controllers\Admin; +use App\Actions\Draw\ClearDraw; use App\Actions\Draw\RunDraw; use App\Http\Controllers\Controller; use App\Http\Requests\ClearDrawRequest; use App\Http\Requests\RunDrawRequest; use App\Models\Audition; use App\Models\Event; -use App\Services\DrawService; use Illuminate\Http\Request; use function array_keys; @@ -16,13 +16,6 @@ use function to_route; class DrawController extends Controller { - protected $drawService; - - public function __construct(DrawService $drawService) - { - $this->drawService = $drawService; - } - public function index(Request $request) { $events = Event::with('auditions.flags')->get(); @@ -41,7 +34,7 @@ class DrawController extends Controller // Code below results in a collection of auditions that were checked on the form $auditions = Audition::with('flags')->findMany(array_keys($request->input('audition', []))); - if ($this->drawService->checkCollectionForDrawnAuditions($auditions)) { + if ($auditions->contains(fn ($audition) => $audition->hasFlag('drawn'))) { return to_route('admin.draw.index')->with('error', 'Cannot run draw. Some auditions have already been drawn.'); } @@ -71,7 +64,7 @@ class DrawController extends Controller // Request will contain audition which is an array of audition IDs all with a value of 1 // Code below results in a collection of auditions that were checked on the form $auditions = Audition::with('flags')->findMany(array_keys($request->input('audition', []))); - $this->drawService->clearDrawsOnCollection($auditions); + app(ClearDraw::class)($auditions); return to_route('admin.draw.index')->with('success', 'Draws cleared successfully');