@@ -74,31 +74,27 @@ protected function getQueryColumns(array $columns) : string
7474
7575 protected function getWhereClauses (array $ wheres = []) : string
7676 {
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+ }
8782
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+ }
9186
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+ }
9590
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 );
9994
100- return "{$ carry }- {$ where ['column ' ]}_ {$ value }" ;
101- }) . '' ;
95+ return "{$ carry }- {$ where ['column ' ]}_ {$ value }" ;
96+ })
97+ . '' ;
10298 }
10399
104100 protected function getWithModels () : string
@@ -256,4 +252,15 @@ protected function getValuesClause($where)
256252 ? '_ ' . implode ('_ ' , $ where ['values ' ])
257253 : '' ;
258254 }
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+ }
259266}
0 commit comments