feat: added settings in room to kick

This commit is contained in:
2026-09-06 16:06:12 +02:00
parent 1e0f5cf143
commit 817b1ce1cb
10 changed files with 439 additions and 107 deletions
+34 -6
View File
@@ -14,13 +14,41 @@ class KickRoomPlayerRequest extends FormRequest
public function authorize(): bool
{
$room = $this->route('room');
$player = $this->route('player');
$targetPlayer = $this->route('player');
return $room instanceof Room
&& $player instanceof Player
&& $this->user()?->id === $room->owner_id
&& $player->room_id === $room->id
&& $player->user_id !== $room->owner_id;
if (
! $room instanceof Room
|| ! $targetPlayer instanceof Player
|| $targetPlayer->room_id !== $room->id
|| $targetPlayer->is_moderator
|| ($room->owner_id !== null && $targetPlayer->user_id === $room->owner_id)
) {
return false;
}
$user = $this->user();
if ($user !== null && $user->id === $room->owner_id) {
return true;
}
$currentPlayer = $this->currentPlayer($room);
return ! $room->isClosed()
&& $currentPlayer !== null
&& $currentPlayer->id !== $targetPlayer->id
&& ($currentPlayer->is_moderator || $room->allow_participants_to_manage_rounds);
}
public function currentPlayer(Room $room): ?Player
{
$playerId = $this->session()->get("room_players.{$room->id}");
if (! is_numeric($playerId)) {
return null;
}
return $room->activePlayers()->find((int) $playerId);
}
/**