@@ -96,25 +96,54 @@ protected function getWhereClauses(array $wheres = []) : string
96
96
{
97
97
return $ this ->getWheres ($ wheres )
98
98
->reduce (function ($ carry , $ where ) {
99
- if (in_array ($ where ['type ' ], ['Exists ' , 'Nested ' , 'NotExists ' ])) {
100
- return '_ ' . strtolower ($ where ['type ' ]) . $ this ->getWhereClauses ($ where ['query ' ]->wheres );
101
- }
99
+ $ value = $ this ->getNestedClauses ($ where );
100
+ $ value .= $ this ->getColumnClauses ($ where );
101
+ $ value .= $ this ->getRawClauses ($ where );
102
+ $ value .= $ this ->getOtherClauses ($ where , $ carry );
102
103
103
- if ($ where ['type ' ] === 'Column ' ) {
104
- return "_ {$ where ['boolean ' ]}_ {$ where ['first ' ]}_ {$ where ['operator ' ]}_ {$ where ['second ' ]}" ;
105
- }
104
+ return $ value ;
105
+ })
106
+ . '' ;
107
+ }
106
108
107
- if ($ where ['type ' ] === 'raw ' ) {
108
- return "_ {$ where ['boolean ' ]}_ " . str_slug ($ where ['sql ' ]);
109
- }
109
+ protected function getNestedClauses (array $ where ) : string
110
+ {
111
+ if (! in_array ($ where ['type ' ], ['Exists ' , 'Nested ' , 'NotExists ' ])) {
112
+ return '' ;
113
+ }
110
114
111
- $ value = array_get ($ where , 'value ' );
112
- $ value .= $ this ->getTypeClause ($ where );
113
- $ value .= $ this ->getValuesClause ($ where );
115
+ return '_ ' . strtolower ($ where ['type ' ]) . $ this ->getWhereClauses ($ where ['query ' ]->wheres );
116
+ }
114
117
115
- return "{$ carry }- {$ where ['column ' ]}_ {$ value }" ;
116
- })
117
- . '' ;
118
+ protected function getColumnClauses (array $ where ) : string
119
+ {
120
+ if ($ where ['type ' ] !== 'Column ' ) {
121
+ return '' ;
122
+ }
123
+
124
+ return "_ {$ where ['boolean ' ]}_ {$ where ['first ' ]}_ {$ where ['operator ' ]}_ {$ where ['second ' ]}" ;
125
+ }
126
+
127
+ protected function getRawClauses (array $ where ) : string
128
+ {
129
+ if ($ where ['type ' ] !== 'raw ' ) {
130
+ return '' ;
131
+ }
132
+
133
+ return "_ {$ where ['boolean ' ]}_ " . str_slug ($ where ['sql ' ]);
134
+ }
135
+
136
+ protected function getOtherClauses (array $ where , string $ carry = null ) : string
137
+ {
138
+ if (in_array ($ where ['type ' ], ['Exists ' , 'Nested ' , 'NotExists ' , 'raw ' , 'Column ' ])) {
139
+ return '' ;
140
+ }
141
+
142
+ $ value = array_get ($ where , 'value ' );
143
+ $ value .= $ this ->getTypeClause ($ where );
144
+ $ value .= $ this ->getValuesClause ($ where );
145
+
146
+ return "{$ carry }- {$ where ['column ' ]}_ {$ value }" ;
118
147
}
119
148
120
149
protected function getWheres (array $ wheres ) : Collection
0 commit comments