mirror of
https://github.com/ericasch6/scrum-poker-internal.git
synced 2026-10-13 23:12:08 +00:00
38 lines
794 B
PHP
38 lines
794 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Requests\SubmitVoteRequest;
|
|
use App\Models\Player;
|
|
use App\Models\Room;
|
|
use App\Services\Rooms\VoteService;
|
|
use Illuminate\Http\Response;
|
|
|
|
class VoteController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly VoteService $votes,
|
|
) {}
|
|
|
|
public function store(
|
|
SubmitVoteRequest $request,
|
|
Room $room,
|
|
): Response {
|
|
$player = $request->attributes->get('currentPlayer');
|
|
|
|
abort_unless(
|
|
$player instanceof Player
|
|
&& $player->room_id === $room->id,
|
|
403,
|
|
);
|
|
|
|
$this->votes->submit(
|
|
$room,
|
|
$player,
|
|
$request->validated('value'),
|
|
);
|
|
|
|
return response()->noContent();
|
|
}
|
|
}
|