add test for admin DrawController. Work on deprecating DrawService
This commit is contained in:
parent
7efe029ff9
commit
74b9d3f141
|
|
@ -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');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue