src/Execution/QueryFilter.php
public function filter($query, array $args = [])
    {
        $valuesGroupedByFilterKey = [];

        /**
         * @var string
         * @var mixed  $value
         */
        foreach ($args as $key => $value) {
            /**
             * @var string
             * @var string[] $argNames
             */
            foreach ($this->multiArgumentFiltersArgNames as $filterKey => $argNames) {
                // Group together the values if multiple arguments are given the same key
                if (in_array($key, $argNames)) {
                    $valuesGroupedByFilterKey[$filterKey][] = $value;
                }
            }

            // Filters that only take a single argument can be applied directly
            if ($filterInfo = Arr::get($this->singleArgumentFilters, $key)) {
                /** @var \Nuwave\Lighthouse\Support\Contracts\ArgFilterDirective $argFilterDirective */
                $argFilterDirective = $filterInfo['filter'];
                $columnName = $filterInfo['columnName'];

                $query = $argFilterDirective->applyFilter($query, $columnName, $value);
            }
        }

        /**
         * @var string
         * @var array  $values
         */
        foreach ($valuesGroupedByFilterKey as $filterKey => $values) {
            $columnName = Str::before($filterKey, '.');

            if ($values) {
                $argFilterDirective = $this->multiArgumentFilters[$filterKey];

                $query = $argFilterDirective->applyFilter($query, $columnName, $values);
            }
        }

        return $query;
    }
public function filter($query, array $args = [])
    {
        $valuesGroupedByFilterKey = [];

        /**
         * @var string
         * @var mixed  $value
         */
        foreach ($args as $key => $value) {
            /**
             * @var string
             * @var string[] $argNames
             */
            foreach ($this->multiArgumentFiltersArgNames as $filterKey => $argNames) {
                // Group together the values if multiple arguments are given the same key
                if (in_array($key, $argNames)) {
                    $valuesGroupedByFilterKey[$filterKey][] = $value;
                }
            }

            // Filters that only take a single argument can be applied directly
            if ($filterInfo = Arr::get($this->singleArgumentFilters, $key)) {
                /** @var \Nuwave\Lighthouse\Support\Contracts\ArgFilterDirective $argFilterDirective */
                $argFilterDirective = $filterInfo['filter'];
                $columnName = $filterInfo['columnName'];

                $query = $argFilterDirective->applyFilter($query, $columnName, $value);
            }
        }

        /**
         * @var string
         * @var array  $values
         */
        foreach ($valuesGroupedByFilterKey as $filterKey => $values) {
            $columnName = Str::before($filterKey, '.');

            if ($values) {
                $argFilterDirective = $this->multiArgumentFilters[$filterKey];

                $query = $argFilterDirective->applyFilter($query, $columnName, $values);
            }
        }

        return $query;
    }
public function filter ( $ query , array $ args = [ ] ) { $ valuesGroupedByFilterKey = [ ] ; /**
         * @var string
         * @var mixed  $value
         */ foreach ( $ args as $ key => $ value ) { /**
             * @var string
             * @var string[] $argNames
             */ foreach ( $ this -> multiArgumentFiltersArgNames as $ filterKey => $ argNames ) { // Group together the values if multiple arguments are given the same key if ( in_array ( $ key , $ argNames ) ) { $ valuesGroupedByFilterKey [ $ filterKey ] [ ] = $ value ; } } // Filters that only take a single argument can be applied directly if ( $ filterInfo = Arr :: get ( $ this -> singleArgumentFilters , $ key ) ) { /** @var \Nuwave\Lighthouse\Support\Contracts\ArgFilterDirective $argFilterDirective */ $ argFilterDirective = $ filterInfo [ 'filter' ] ; $ columnName = $ filterInfo [ 'columnName' ] ; $ query = $ argFilterDirective -> applyFilter ( $ query , $ columnName , $ value ) ; } } /**
         * @var string
         * @var array  $values
         */ foreach ( $ valuesGroupedByFilterKey as $ filterKey => $ values ) { $ columnName = Str :: before ( $ filterKey , '.' ) ; if ( $ values ) { $ argFilterDirective = $ this -> multiArgumentFilters [ $ filterKey ] ; $ query = $ argFilterDirective -> applyFilter ( $ query , $ columnName , $ values ) ; } } return $ query ; }
Apply all registered filters to the query.

@param  \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder  $query
@param  array  $args
@return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder
Apply all registered filters to the query .