Prefix query bindings and wheres with the relation's model Node placeholder.

@param  \Vinelab\NeoEloquent\Eloquent\Builder $query
@param  string  $prefix
@return void
161405
protected function prefixAndMerge(Builder $query, $prefix)
    {
        $this->prefixWheres($query, $prefix);
        $this->query->mergeWheres($query->getQuery()->wheres, $query->getQuery()->getBindings());
    }
439265
public function compileEdge(Builder $query, $parent, $related, $relationship = 'E', $values = [])
    {
        // Essentially we will force every insert to be treated as a batch insert which
        // simply makes creating the SQL easier for us since we can utilize the same
        // basic routine regardless of an amount of records given to us to insert.

        $from = $this->columnize([$parent->getAttributes()[$parent->getKeyName()]]);
        $to = $this->columnize([$related->getAttributes()[$related->getKeyName()]]);

//     code to check if relationship object exist or not
//        
//              if($relationship instanceof Relatio){
//            
//        }
        // Add content if there are the $values present
        $property_query = NULL;
        if ($values != NULL) {
            $property_query = "CONTENT " . json_encode($values);
        }
        return "create edge {$relationship->getType()} from $from to $to " . $property_query;

    }
187644
protected function user(Builder $query)
    {
        // We'll try to locate the user by their object guid,
        // otherwise we'll locate them by their username.
        $query
            ->where(Resolver::getDatabaseIdColumn(), '=', $this->getGuid())
            ->orWhere(Resolver::getDatabaseUsernameColumn(), '=', $this->getUsername());
    }
95248
public function initSelectQuery($model, $query)
    {
        // if ON is set, we don't have to worry about anything
        if ($this->on) {
            $query->join(
                $this->foreign_table.' '.$this->foreign_alias,
                $this->on instanceof \atk4\dsql\Expression ? $this->on : $model->expr($this->on),
                $this->kind
            );

            return;
        }

        $query->join(
            $this->foreign_table.(isset($this->foreign_alias) ? (' '.$this->foreign_alias) : ''),
            $model->expr('{}.{} = {}', [
                (isset($this->foreign_alias) ? $this->foreign_alias : $this->foreign_table),
                $this->foreign_field,
                $this->owner->getField($this->master_field),
            ]),
            $this->kind
        );

        /*
        if ($this->reverse) {
            $query->field([$this->short_name => ($this->join ?:
                (
                    (isset($this->owner->table_alias) ? $this->owner->table_alias : $this->owner->table)
                    .'.'.$this->master_field)
            )]);
        } else {
            $query->field([$this->short_name => $this->foreign_alias.'.'.$this->foreign_field]);
        }
         */
    }
1332251
public function mergeBindings(Builder $query)
    {
        $this->bindings = array_merge_recursive($this->bindings, $query->bindings);

        return $this;
    }
463350
public function formExtendQuery($query)
    {
        if (!$this->user->isSuperUser()) {
            $query->where('is_superuser', false);
        }

        // Ensure soft-deleted records can still be managed
        $query->withTrashed();
    }
1052577
protected function applySortClauses(Builder $query): void
    {
        $sortBy = $this->getAttribute('request')->get('sortBy', $this->getAttribute('sortBy'));
        $sortDir = $this->getAttribute('request')->get('sortDir', $this->getAttribute('sortDir'));
        if ($sortBy && $sortDir) {
            $query->orderBy($sortBy, $sortDir);
            $this->setAttribute('sortBy', $sortBy);
            $this->setAttribute('sortDir', $sortDir);
        }
    }
669275
public function visit($query, NodeContract $node, string $context)
    {
        if ($node instanceof Nodes\KeyNode) {
            $key = $node->getValue();

            $keys = explode('.', $key);

            if (count($keys) === 1) {
                $keys = [$this->getBaseTable(), $keys[0]];
            }

            $key = implode('.', $keys);

            $node->setValue($key);

            if ($this->getKeys()[0] === '*') {
                return;
            }

            if (!in_array($key, $this->getKeys())) {
                throw new QuerySyntaxException();
            }
        }

        foreach ($node->getChildren() as $child) {
            $this->visit($query, $child, $context);
        }
    }
1146840
public function newEloquentBuilder($query)
    {
        return \tap(new Builder($query), function ($builder) {
            $builder->setTenantor($this->tenantor ?? null);
        });
    }
760826
protected function setKeysForSaveQuery(Builder $query)
    {
        parent::setKeysForSaveQuery($query);
        $query->where('locale', '=', $this->locale);

        return $query;
    }
1179513
protected function removeBinding(BaseBuilder $query, $key)
    {
        $bindings = $query->getRawBindings()['where'];

        unset($bindings[ $key ]);

        $query->setBindings($bindings);
    }
906756
public static function canonquery($query, $prefix = '')
    {
        parse_str(preg_replace('#^\?#', '', $query), $args);

        if (empty($args)) {
            return '';
        }

        ksort($args);
        return $prefix . http_build_query($args);
    }
16632
protected function setKeysForSaveQuery(Builder $query)
    {
        $query->where($this->getKeyName(), '=', $this->getKeyForSaveQuery());

        return $query;
    }
310977
function prefixQuery( $regex, $query, $prefix = NULL ) {
		if( !isset( $prefix ) ) {
			return $query;
		}

		if( preg_match( $regex, $query, $match ) ) {
			$preamble = $match[1];
			$postamble = $match[5];
			$objectList = explode( ',', $match[3] );
			// $prefix = $prefix . '_';

			$prefixedList = '';

			foreach( $objectList as $object ) {
				if( $prefixedList !== '' ) {
					$prefixedList .= ', ';
				}

				$prefixedList .= $prefix . trim( $object );
			}

			$query = $preamble . ' ' . $prefixedList . ' ' . $postamble;
		}

		return $query;
	}
509009
public function getRelationQuery(Builder $query, Builder $parent, $columns = ['*'])
    {
        $table = $this->getParent()->getTable();
        $query = parent::getRelationQuery($query, $parent, $columns);

        return $query->where("{$table}.{$this->morphType}", '=', $this->morphName);
    }
630061
private function queryJoinBuilder($query, $relation)
    {
        $relatedTable = $relation->getRelated()->getTable();
        $parentTable  = $relation->getParent()->getTable();

        if ($parentTable === $relatedTable) {
            $query       = $query->from($parentTable.' as parent_'.$parentTable);
            $parentTable = 'parent_'.$parentTable;
            $relation->getParent()->setTable($parentTable);
        }

        if ($relation instanceof HasOne) {
            $relatedPrimaryKey = $relation->getQualifiedForeignKeyName();
            $parentPrimaryKey  = $relation->getQualifiedParentKeyName();
        } elseif ($relation instanceof BelongsTo) {
            $relatedPrimaryKey = $relation->getQualifiedOwnerKeyName();
            $parentPrimaryKey  = $relation->getQualifiedForeignKeyName();
        } else {
            throw new \Exception();
        }

        return $this->formJoin($query, $parentTable, $relatedTable, $parentPrimaryKey, $relatedPrimaryKey);
    }
454395
public function applyAll(Builder $query)
    {
        foreach($this->units as $unit)
        {
            $unit->apply($query);
        }
    }