@param Repository $query

@return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed
3449
public function build(Repository $query)
    {
        $filters = collect($this->filters());
        $count = $filters->count();

        if ($count === 0) {
            return;
        }

        foreach ($filters as $key => $filter) {
            $filters[$key] = new $filter();
        }

        return view($this->template, [
            'filters' => $filters,
            'chunk'   => ceil($count / 4),
        ]);
    }
428126
public function apply($model, \Prettus\Repository\Contracts\RepositoryInterface $repository)
    {
        $limit = $this->request->get('limit', null);
        $offset = $this->request->get('offset', null);

        if ($limit) {
            $model = $model->limit($limit);
        }

        if ($offset && $limit) {
            $model = $model->skip($offset);
        }

        return $model;
    }
589397
public function execute($query) {
		$query = $query->compile();
		return $this->driver->query($query->sql(), $query->params());
	}
81685
public function build(&$query)
    {
        $segments = array();

        if (isset($query['oid'])) {
            $segments[] = '@'.$query['oid'];
        }

        if (isset($query['q'])) {
            $segments[] = $query['q'];
        }

        //we don't need the view
        unset($query['view']);
        unset($query['oid']);
        unset($query['q']);

        return $segments;
    }
948935
protected function loadByQuery(Query $query)
    {
        $result = $this->doQuery($query);

        if ($result->getNumRows() == 0) {
            return null;
        }

        $this->fillProperties($result->fetch());

        return $this;
    }
903932
private function runQuery($query)
    {
        $resultSetMapping = (new ResultSetMapping())
                ->addScalarResult('id', 'id')
                ->addScalarResult('type', 'type')
                ->addScalarResult('date', 'date');
        
        return $this->em->createNativeQuery($query, $resultSetMapping)
                ->getArrayResult();
    }
1045719
public function build(Repository $query)
    {
        $columns = collect($this->fields())->filter(function (TD $item) {
            return $item->isSee();
        });

        return view($this->template, [
            'data'     => $query->getContent($this->data),
            'columns'  => $columns,
        ]);
    }
786773
protected function parseRQL($query) {
    if (strlen($query) > 0) {
      // replace rql operators
      $operatorMap = ['eq' => '=', 'ne' => '!=', 'lt' => '<', 'lte' => '<=',
          'gt' => '>', 'gte' => '>=', 'in' => 'in', 'match' => 'regexp', '=' => '='];
      $combineMap = ['|' => 'OR', '&' => 'AND'];
      $queryType = $this->getQueryType();
      $mapper = self::getMapper($queryType);
      $persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
      foreach ($operatorMap as $rqlOp => $sqlOp) {
        // add '=' separator for letter-only operators
        $operator = preg_match('/^[a-zA-Z]+$/', $rqlOp) ? '='.$rqlOp.'=' : $rqlOp;
        $query = preg_replace_callback('/([^ <>!=|&\(\)]+) ?'.$operator.' ?([^ <>!=|&\(\)]+)/', function ($match)
                use($rqlOp, $sqlOp, $mapper, $persistenceFacade) {
          $typeAttr = $match[1];
          $value = preg_replace('/^[\'"]|[\'"]$/', '', $match[2]);

          // try to determine value type
          list($typeOrRole, $attribute) = explode('.', preg_replace('/[`"\'\(\)]/', '', $typeAttr), 2);
          $attributeDef = null;
          if ($persistenceFacade->isKnownType($typeOrRole) &&
                  $persistenceFacade->getFullyQualifiedType($typeOrRole) == $mapper->getType() && $mapper->hasAttribute($attribute)) {
            $attributeDef = $mapper->getAttribute($attribute);
          }
          elseif ($mapper->hasRelation($typeOrRole)) {
            $otherMapper = self::getMapper($mapper->getRelation($typeOrRole)->getOtherType());
            $attributeDef = $otherMapper->hasAttribute($attribute) ? $otherMapper->getAttribute($attribute) : null;
          }
          $attributeType = $attributeDef != null ? strtolower($attributeDef->getType()) : null;
          $isNumber = $attributeType == 'integer' || $attributeType == 'float';

          // strip slashes from regexp
          if ($sqlOp === 'regexp') {
            $value = preg_replace('/^\/|\/[a-zA-Z]*$/', '', $value);
          }

          // handle null values
          if ($value === 'null') {
            $sqlOp = $sqlOp == '=' ? 'is' : 'is not';
            $replace = $typeAttr.' '.$sqlOp.' null';
          }
          else {
            // quote value according to type
            $replace = $typeAttr.' '.$sqlOp.' ';
            if ($rqlOp == 'in') {
              $replace .= '('.($isNumber ? $value : join(',', array_map([$mapper, 'quoteValue'], explode(',', $value)))).')';
            }
            else {
              $replace .= $isNumber ? $value : $mapper->quoteValue($value);
            }
          }

          return $replace;
        }, $query);
      }
      foreach ($combineMap as $rqlOp => $sqlOp) {
        $query = str_replace($rqlOp, ' '.$sqlOp.' ', $query);
      }
    }
    return $query;
  }
960900
public function build($query)
    {
        //clone the query so it won't be modified
        $query = clone $query;
        $parts = array();
        $this->_query = $query;
        $this->_store = $query->getRepository()->getStore();
        switch ($query->operation['type']) {
            case AnDomainQuery::QUERY_SELECT_DEFAULT :
            case AnDomainQuery::QUERY_SELECT  :
                $parts[] = $this->select($query);
                $parts[] = $this->from($query);
                $parts[] = '@MYSQL_JOIN_PLACEHOLDER';
                $parts[] = $this->where($query);
                $parts[] = $this->group($query);
                $parts[] = $this->having($query);
                $parts[] = $this->order($query);
                $parts[] = $this->limit($query);
                break;
            case AnDomainQuery::QUERY_UPDATE :
                $parts[] = $this->update($query);
                $parts[] = $this->where($query);
                $parts[] = $this->order($query);
                $parts[] = $this->limit($query);
                break;
            case AnDomainQuery::QUERY_DELETE :
                $parts[] = $this->delete($query);
                $parts[] = $this->from($query);
                $parts[] = $this->where($query);
                break;
            default :
                _die();
        }

        $string = implode(' ', $parts);
        $string = $this->parseMethods($query, $string);
        $string = str_replace('@MYSQL_JOIN_PLACEHOLDER', $this->join($query), $string);
        $string = $this->parseMethods($query, $string);

        if (!empty($query->binds)) {
            foreach ($query->binds as $key => $value) {
                $key = ':'.$key;
                $value = $this->_store->quoteValue($value);
                $string = str_replace($key, $value, $string);
            }
        }

        $string = str_replace('@DISTINCT', $query->distinct ? 'DISTINCT' : '', $string);

        return    $string;
    }
258264
public function merge(Query $query): Query
    {
        foreach ($query->getCriteria() as $criterion) {
            $criterion->attach($this);
        }

        return $this->attach($query);
    }
1212462
public function query($query=null)
    {
        if (!static::isSql($query)) {
            $this->checkQuery($query);
            $query = null;
        }
        
        return $this->getDb()->setQuery($this->getQuery())->query($query);
    }
381487
protected function executeQuery($query)
    {
        $query   = null !== $this->getLocale() ? sprintf('%s&language=%s', $query, $this->getLocale()) : $query;
        $content = $this->getAdapter()->get($query)->getBody();

        if (!$data = json_decode($content, true)) {
            throw new NoResult(sprintf('Could not execute query: %s', $query));
        }

        if (!isset($data['Response']) && 'InvalidCredentials' === $data['subtype']) {
            throw new InvalidCredentials(sprintf('Invalid credentials: %s', $data['details']));
        } elseif (!isset($data['Response'])) {
            throw new NoResult(
                sprintf('Error type `%s` returned from api `%s`', $data['subtype'], $data['Details'])
            );
        }

        if (empty($data['Response']['View'])) {
            throw new NoResult(sprintf('Could not find results for given query: %s', $query));
        }

        $locations = $data['Response']['View'][0]['Result'];

        $results = array();
        foreach ($locations as $location) {
            $location       = $location['Location'];
            $coordinates    = isset($location['NavigationPosition'][0]) ? $location['NavigationPosition'][0] : $location['DisplayPosition'];
            $bounds         = $location['MapView'];
            $address        = $location['Address'];
            $additionalData = $location['Address']['AdditionalData'];

            $results[] = array_merge($this->getDefaults(), array(
                'latitude'     => $coordinates['Latitude']  ?: null,
                'longitude'    => $coordinates['Longitude'] ?: null,
                'bounds'       => array(
                    'south' => $bounds['BottomRight']['Latitude']  ?: null,
                    'west'  => $bounds['TopLeft']['Longitude']     ?: null,
                    'north' => $bounds['TopLeft']['Latitude']      ?: null,
                    'east'  => $bounds['BottomRight']['Longitude'] ?: null,
                ),
                'streetNumber' => isset($address['HouseNumber']) ? $address['HouseNumber'] : null,
                'streetName'   => isset($address['Street'])      ? $address['Street']      : null,
                'city'         => isset($address['City'])        ? $address['City']        : null,
                'cityDistrict' => isset($address['District'])    ? $address['District']    : null,
                'zipcode'      => isset($address['PostalCode'])  ? $address['PostalCode']  : null,
                'county'       => isset($address['County'])      ? $address['County']      : null,
                'regionCode'   => isset($address['State'])       ? $address['State']       : null,
                'countryCode'  => isset($address['Country'])     ? $address['Country']     : null,
                'region'       => $this->findByKey('StateName', $additionalData),
                'country'      => $this->findByKey('CountryName', $additionalData),
                'countyCode'   => null,
            ));
        }

        return $results;
    }
904586
public function execute(Query $query)
    {
        // Get native query for SimpleExpression
        $nativeQuery = $this->getNativeQuery($query);

        $queryParts = array();
        parse_str($nativeQuery, $queryParts);

        // pass http query parts 
        return $this->getClient()->lookup($queryParts);
    }
1200230
public function findRaw($query) {
        $this->_type = self::QUERY_RAW;
        $this->_query = $query;

        return $this;
    }
804643
public function all($query)
    {
        $authSession = $this->repositoryDispatcher->getCookieAuthSession();

        $response = $this->client->request('POST', $this->endpoint . '/rest/api/2/search', [
            RequestOptions::HEADERS => [
                'Cookie' => $authSession->getName() . '=' . $authSession->getValue(),
            ],
            RequestOptions::JSON => $query,
        ]);

        $body = $response->getBody();
        $body->seek(0);
        $contents = $body->getContents();

        $decodedContents = json_decode($contents, true);

        $issues = [];
        if (isset($decodedContents['issues']) && is_array($decodedContents['issues'])) {
            foreach ($decodedContents['issues'] as $issue) {
                $issues[] = $this->createInstance($issue);
            }
        }

        return $issues;
    }
786535
private function getBuilder($query)
    {
        $queryType = $query->getType();

        if (!isset($this->builders[$queryType])) {
            throw new \InvalidArgumentException("Unknow query builder for {$queryType}.");
        }

        return $this->builders[$queryType];
    }
1037099
public function query($query) {
		$args = func_get_args();
		$query = array_shift($args);
		return $this->execute($query, $args);
	}