@@ -111,30 +111,40 @@ protected function getValuesClause(array $where = null) : string
111
111
}
112
112
113
113
$ values = $ this ->getValuesFromWhere ($ where );
114
- $ values = $ this ->getValuesFromBindings ($ values );
114
+ $ values = $ this ->getValuesFromBindings ($ where , $ values );
115
+
116
+
115
117
116
118
return "_ " . $ values ;
117
119
}
118
120
119
121
protected function getValuesFromWhere (array $ where ) : string
120
122
{
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 " , "" );
124
128
}
125
129
126
- protected function getValuesFromBindings (string $ values ) : string
130
+ protected function getValuesFromBindings (array $ where , string $ values ) : string
127
131
{
128
- if (! $ values && $ this ->query ->bindings ["where " ] ?? false ) {
132
+ if (! $ values && ( $ this ->query ->bindings ["where " ] ?? false ) ) {
129
133
$ 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
+ }
130
140
}
131
141
132
- return $ values ;
142
+ return $ values ?: "" ;
133
143
}
134
144
135
145
protected function getWhereClauses (array $ wheres = []) : string
136
146
{
137
- $ whereClause = $ this ->getWheres ($ wheres )
147
+ return "" . $ this ->getWheres ($ wheres )
138
148
->reduce (function ($ carry , $ where ) {
139
149
$ value = $ carry ;
140
150
$ value .= $ this ->getNestedClauses ($ where );
@@ -143,10 +153,7 @@ protected function getWhereClauses(array $wheres = []) : string
143
153
$ value .= $ this ->getOtherClauses ($ where , $ carry );
144
154
145
155
return $ value ;
146
- })
147
- . "" ;
148
-
149
- return $ whereClause ;
156
+ });
150
157
}
151
158
152
159
protected function getNestedClauses (array $ where ) : string
@@ -157,7 +164,7 @@ protected function getNestedClauses(array $where) : string
157
164
158
165
$ this ->currentBinding ++;
159
166
160
- return "_ " . strtolower ($ where ["type " ]) . $ this ->getWhereClauses ($ where ["query " ]->wheres );
167
+ return "- " . strtolower ($ where ["type " ]) . $ this ->getWhereClauses ($ where ["query " ]->wheres );
161
168
}
162
169
163
170
protected function getColumnClauses (array $ where ) : string
@@ -168,7 +175,7 @@ protected function getColumnClauses(array $where) : string
168
175
169
176
$ this ->currentBinding ++;
170
177
171
- return "_ {$ where ["boolean " ]}_ {$ where ["first " ]}_ {$ where ["operator " ]}_ {$ where ["second " ]}" ;
178
+ return "- {$ where ["boolean " ]}_ {$ where ["first " ]}_ {$ where ["operator " ]}_ {$ where ["second " ]}" ;
172
179
}
173
180
174
181
protected function getRawClauses (array $ where ) : string
@@ -192,7 +199,7 @@ protected function getRawClauses(array $where) : string
192
199
$ clause .= "_ " . $ lastPart ;
193
200
}
194
201
195
- return str_replace (" " , "_ " , $ clause );
202
+ return " - " . str_replace (" " , "_ " , $ clause );
196
203
}
197
204
198
205
protected function getOtherClauses (array $ where , string $ carry = null ) : string
@@ -203,9 +210,8 @@ protected function getOtherClauses(array $where, string $carry = null) : string
203
210
204
211
$ value = $ this ->getTypeClause ($ where );
205
212
$ value .= $ this ->getValuesClause ($ where );
206
- $ this ->currentBinding ++;
207
213
208
- return "{$ where ["column " ]}_ {$ value }" ;
214
+ return "- {$ where ["column " ]}_ {$ value }" ;
209
215
}
210
216
211
217
protected function getWheres (array $ wheres ) : Collection
0 commit comments