lockForUpdate() ->findOrFail($room->id); if ($lockedRoom->isClosed()) { throw ValidationException::withMessages([ 'value' => 'Dieser Raum ist geschlossen.', ]); } if ($lockedRoom->revealed_at !== null) { throw ValidationException::withMessages([ 'value' => 'Die Karten wurden bereits aufgedeckt.', ]); } Vote::updateOrCreate( [ 'room_id' => $lockedRoom->id, 'player_id' => $player->id, 'round' => $lockedRoom->current_round, ], ['value' => $value], ); $lockedRoom->update([ 'last_activity_at' => now(), 'state_version' => $lockedRoom->state_version + 1, ]); return $lockedRoom->state_version; }); RoomStateChanged::dispatch( $room->id, $stateVersion, RoomStateChange::VoteChanged, ); } }