code: public static function createFromQueryBuilder(QueryBuilder $builder, $columnName = 'id')
      {
          return new self(
              $builder->getSQL(),
              $builder->getParameters(),
              $columnName,
              $builder->getConnection(),
              $builder->getParameterTypes()
          );
      }
docs: Create a rule instance from the passed query builder.
  
  @param QueryBuilder $builder    The builder to extract query information from.
  
  @param string       $columnName The column to retrieve.
  
  @return SimpleQuery