@@ -111,30 +111,40 @@ protected function getValuesClause(array $where = null) : string
111111 }
112112
113113 $ values = $ this ->getValuesFromWhere ($ where );
114- $ values = $ this ->getValuesFromBindings ($ values );
114+ $ values = $ this ->getValuesFromBindings ($ where , $ values );
115+
116+
115117
116118 return "_ " . $ values ;
117119 }
118120
119121 protected function getValuesFromWhere (array $ where ) : string
120122 {
121- return is_array (array_get ($ where , "values " ))
122- ? implode ("_ " , $ where ["values " ])
123- : "" ;
123+ if (is_array (array_get ($ where , "values " ))) {
124+ return implode ("_ " , $ where ["values " ]);
125+ }
126+
127+ return array_get ($ where , "value " , "" );
124128 }
125129
126- protected function getValuesFromBindings (string $ values ) : string
130+ protected function getValuesFromBindings (array $ where , string $ values ) : string
127131 {
128- if (! $ values && $ this ->query ->bindings ["where " ] ?? false ) {
132+ if (! $ values && ( $ this ->query ->bindings ["where " ] ?? false ) ) {
129133 $ values = $ this ->query ->bindings ["where " ][$ this ->currentBinding ];
134+ $ this ->currentBinding ++;
135+
136+ if ($ where ["type " ] === "between " ) {
137+ $ values .= "_ " . $ this ->query ->bindings ["where " ][$ this ->currentBinding ];
138+ $ this ->currentBinding ++;
139+ }
130140 }
131141
132- return $ values ;
142+ return $ values ?: "" ;
133143 }
134144
135145 protected function getWhereClauses (array $ wheres = []) : string
136146 {
137- $ whereClause = $ this ->getWheres ($ wheres )
147+ return "" . $ this ->getWheres ($ wheres )
138148 ->reduce (function ($ carry , $ where ) {
139149 $ value = $ carry ;
140150 $ value .= $ this ->getNestedClauses ($ where );
@@ -143,10 +153,7 @@ protected function getWhereClauses(array $wheres = []) : string
143153 $ value .= $ this ->getOtherClauses ($ where , $ carry );
144154
145155 return $ value ;
146- })
147- . "" ;
148-
149- return $ whereClause ;
156+ });
150157 }
151158
152159 protected function getNestedClauses (array $ where ) : string
@@ -157,7 +164,7 @@ protected function getNestedClauses(array $where) : string
157164
158165 $ this ->currentBinding ++;
159166
160- return "_ " . strtolower ($ where ["type " ]) . $ this ->getWhereClauses ($ where ["query " ]->wheres );
167+ return "- " . strtolower ($ where ["type " ]) . $ this ->getWhereClauses ($ where ["query " ]->wheres );
161168 }
162169
163170 protected function getColumnClauses (array $ where ) : string
@@ -168,7 +175,7 @@ protected function getColumnClauses(array $where) : string
168175
169176 $ this ->currentBinding ++;
170177
171- return "_ {$ where ["boolean " ]}_ {$ where ["first " ]}_ {$ where ["operator " ]}_ {$ where ["second " ]}" ;
178+ return "- {$ where ["boolean " ]}_ {$ where ["first " ]}_ {$ where ["operator " ]}_ {$ where ["second " ]}" ;
172179 }
173180
174181 protected function getRawClauses (array $ where ) : string
@@ -192,7 +199,7 @@ protected function getRawClauses(array $where) : string
192199 $ clause .= "_ " . $ lastPart ;
193200 }
194201
195- return str_replace (" " , "_ " , $ clause );
202+ return " - " . str_replace (" " , "_ " , $ clause );
196203 }
197204
198205 protected function getOtherClauses (array $ where , string $ carry = null ) : string
@@ -203,9 +210,8 @@ protected function getOtherClauses(array $where, string $carry = null) : string
203210
204211 $ value = $ this ->getTypeClause ($ where );
205212 $ value .= $ this ->getValuesClause ($ where );
206- $ this ->currentBinding ++;
207213
208- return "{$ where ["column " ]}_ {$ value }" ;
214+ return "- {$ where ["column " ]}_ {$ value }" ;
209215 }
210216
211217 protected function getWheres (array $ wheres ) : Collection
0 commit comments