public function parseNode($query, $node)
    {
        if ($node instanceof Nodes\KeyNode) {
            return $this->parseKey($node->getValue());
        }

        if ($node instanceof Nodes\ValueNode) {
            return $this->parseValue($node->getValue());
        }

        if ($node instanceof Nodes\FunctionNode) {
            // .. ?

            $f = $this->getBuilder()->getFunctions()->first(function ($item, $key) use ($node) {
                $class = $item->getNode();

                return $node instanceof $class;
            });

            if (!$f) {
                throw new \Railken\SQ\Exceptions\QuerySyntaxException();
            }

            $childs = new Collection();

            foreach ($node->getChildren() as $child) {
                $childs[] = $this->parseNode($query, $child);
            }

            $childs = $childs->map(function ($v) use ($query) {
                if ($v instanceof \Illuminate\Database\Query\Expression) {
                    return $v->getValue();
                }

                $query->addBinding($v, 'where');

                return '?';
            });

            return DB::raw($f->getName().'('.$childs->implode(',').')');
        }
    }
public function parseNode($query, $node)
    {
        if ($node instanceof Nodes\KeyNode) {
            return $this->parseKey($node->getValue());
        }

        if ($node instanceof Nodes\ValueNode) {
            return $this->parseValue($node->getValue());
        }

        if ($node instanceof Nodes\FunctionNode) {
            // .. ?

            $f = $this->getBuilder()->getFunctions()->first(function ($item, $key) use ($node) {
                $class = $item->getNode();

                return $node instanceof $class;
            });

            if (!$f) {
                throw new \Railken\SQ\Exceptions\QuerySyntaxException();
            }

            $childs = new Collection();

            foreach ($node->getChildren() as $child) {
                $childs[] = $this->parseNode($query, $child);
            }

            $childs = $childs->map(function ($v) use ($query) {
                if ($v instanceof \Illuminate\Database\Query\Expression) {
                    return $v->getValue();
                }

                $query->addBinding($v, 'where');

                return '?';
            });

            return DB::raw($f->getName().'('.$childs->implode(',').')');
        }
    }
public function parseNode ( $ query , $ node ) { if ( $ node instanceof Nodes \ KeyNode ) { return $ this -> parseKey ( $ node -> getValue ( ) ) ; } if ( $ node instanceof Nodes \ ValueNode ) { return $ this -> parseValue ( $ node -> getValue ( ) ) ; } if ( $ node instanceof Nodes \ FunctionNode ) { // .. ? $ f = $ this -> getBuilder ( ) -> getFunctions ( ) -> first ( function ( $ item , $ key ) use ( $ node ) { $ class = $ item -> getNode ( ) ; return $ node instanceof $ class ; } ) ; if ( ! $ f ) { throw new \ Railken \ SQ \ Exceptions \ QuerySyntaxException ( ) ; } $ childs = new Collection ( ) ; foreach ( $ node -> getChildren ( ) as $ child ) { $ childs [ ] = $ this -> parseNode ( $ query , $ child ) ; } $ childs = $ childs -> map ( function ( $ v ) use ( $ query ) { if ( $ v instanceof \ Illuminate \ Database \ Query \ Expression ) { return $ v -> getValue ( ) ; } $ query -> addBinding ( $ v , 'where' ) ; return '?' ; } ) ; return DB :: raw ( $ f -> getName ( ) . '(' . $ childs -> implode ( ',' ) . ')' ) ; } }
Parse the node.

@param mixed                              $query
@param \Railken\SQ\Contracts\NodeContract $node

@return mixed
Parse the node .