@@ -74,31 +74,27 @@ protected function getQueryColumns(array $columns) : string
74
74
75
75
protected function getWhereClauses (array $ wheres = []) : string
76
76
{
77
- $ wheres = collect ($ wheres );
78
-
79
- if ($ wheres ->isEmpty ()) {
80
- $ wheres = collect ($ this ->query ->wheres );
81
- }
82
-
83
- return $ wheres ->reduce (function ($ carry , $ where ) {
84
- if (in_array ($ where ['type ' ], ['Exists ' , 'Nested ' , 'NotExists ' ])) {
85
- return '_ ' . strtolower ($ where ['type ' ]) . $ this ->getWhereClauses ($ where ['query ' ]->wheres );
86
- }
77
+ return $ this ->getWheres ($ wheres )
78
+ ->reduce (function ($ carry , $ where ) {
79
+ if (in_array ($ where ['type ' ], ['Exists ' , 'Nested ' , 'NotExists ' ])) {
80
+ return '_ ' . strtolower ($ where ['type ' ]) . $ this ->getWhereClauses ($ where ['query ' ]->wheres );
81
+ }
87
82
88
- if ($ where ['type ' ] === 'Column ' ) {
89
- return "_ {$ where ['boolean ' ]}_ {$ where ['first ' ]}_ {$ where ['operator ' ]}_ {$ where ['second ' ]}" ;
90
- }
83
+ if ($ where ['type ' ] === 'Column ' ) {
84
+ return "_ {$ where ['boolean ' ]}_ {$ where ['first ' ]}_ {$ where ['operator ' ]}_ {$ where ['second ' ]}" ;
85
+ }
91
86
92
- if ($ where ['type ' ] === 'raw ' ) {
93
- return "_ {$ where ['boolean ' ]}_ " . str_slug ($ where ['sql ' ]);
94
- }
87
+ if ($ where ['type ' ] === 'raw ' ) {
88
+ return "_ {$ where ['boolean ' ]}_ " . str_slug ($ where ['sql ' ]);
89
+ }
95
90
96
- $ value = array_get ($ where , 'value ' );
97
- $ value .= $ this ->getTypeClause ($ where );
98
- $ value .= $ this ->getValuesClause ($ where );
91
+ $ value = array_get ($ where , 'value ' );
92
+ $ value .= $ this ->getTypeClause ($ where );
93
+ $ value .= $ this ->getValuesClause ($ where );
99
94
100
- return "{$ carry }- {$ where ['column ' ]}_ {$ value }" ;
101
- }) . '' ;
95
+ return "{$ carry }- {$ where ['column ' ]}_ {$ value }" ;
96
+ })
97
+ . '' ;
102
98
}
103
99
104
100
protected function getWithModels () : string
@@ -256,4 +252,15 @@ protected function getValuesClause($where)
256
252
? '_ ' . implode ('_ ' , $ where ['values ' ])
257
253
: '' ;
258
254
}
255
+
256
+ protected function getWheres (array $ wheres ) : Collection
257
+ {
258
+ $ wheres = collect ($ wheres );
259
+
260
+ if ($ wheres ->isEmpty ()) {
261
+ $ wheres = collect ($ this ->query ->wheres );
262
+ }
263
+
264
+ return $ wheres ;
265
+ }
259
266
}
0 commit comments