mirror of
https://github.com/ericasch6/scrum-poker-internal.git
synced 2026-10-13 15:32:09 +00:00
feat: added settings in room to kick
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user