protected function applyRecursive($query, array $targetParts, $value, $isFirst = false)
    {
        if (count($targetParts) < 2) {

            if ($this->translated) {
                return $this->applyTranslatedValue($query, head($targetParts), $value, $isFirst);
            }

            return $this->applyValue($query, head($targetParts), $value, null, $isFirst);
        }

        $relation = array_shift($targetParts);

        $whereHasMethod = ! $isFirst && $this->combineOr ? 'orWhereHas' : 'whereHas';

        return $query->{$whereHasMethod}(
            $relation,
            function ($query) use ($targetParts, $value) {
                return $this->applyRecursive($query, $targetParts, $value, true);
            }
        );
    }
protected function applyRecursive($query, array $targetParts, $value, $isFirst = false)
    {
        if (count($targetParts) < 2) {

            if ($this->translated) {
                return $this->applyTranslatedValue($query, head($targetParts), $value, $isFirst);
            }

            return $this->applyValue($query, head($targetParts), $value, null, $isFirst);
        }

        $relation = array_shift($targetParts);

        $whereHasMethod = ! $isFirst && $this->combineOr ? 'orWhereHas' : 'whereHas';

        return $query->{$whereHasMethod}(
            $relation,
            function ($query) use ($targetParts, $value) {
                return $this->applyRecursive($query, $targetParts, $value, true);
            }
        );
    }
protected function applyRecursive ( $ query , array $ targetParts , $ value , $ isFirst = false ) { if ( count ( $ targetParts ) < 2 ) { if ( $ this -> translated ) { return $ this -> applyTranslatedValue ( $ query , head ( $ targetParts ) , $ value , $ isFirst ) ; } return $ this -> applyValue ( $ query , head ( $ targetParts ) , $ value , null , $ isFirst ) ; } $ relation = array_shift ( $ targetParts ) ; $ whereHasMethod = ! $ isFirst && $ this -> combineOr ? 'orWhereHas' : 'whereHas' ; return $ query -> { $ whereHasMethod } ( $ relation , function ( $ query ) use ( $ targetParts , $ value ) { return $ this -> applyRecursive ( $ query , $ targetParts , $ value , true ) ; } ) ; }
Applies a the filter value recursively for normalized target segments.

@param Builder  $query
@param string[] $targetParts
@param mixed    $value
@param bool     $isFirst      whether this is the first expression (between brackets)
@return mixed
Applies a the filter value recursively for normalized target segments .