route('room'); $targetPlayer = $this->route('player'); 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); } /** * Get the validation rules that apply to the request. * * @return array> */ public function rules(): array { return []; } }