@@ -51,14 +51,15 @@ public function make(
51
51
$ key .= $ this ->getIdColumn ($ idColumn ?: "" );
52
52
$ key .= $ this ->getQueryColumns ($ columns );
53
53
$ key .= $ this ->getWhereClauses ();
54
+ $ key .= $ this ->getHavingClauses ();
54
55
$ key .= $ this ->getWithModels ();
55
56
$ key .= $ this ->getOrderByClauses ();
56
57
$ key .= $ this ->getOffsetClause ();
57
58
$ key .= $ this ->getLimitClause ();
58
59
$ key .= $ this ->getBindingsSlug ();
59
60
$ key .= $ keyDifferentiator ;
60
61
$ key .= $ this ->macroKey ;
61
- // dump($key);
62
+
62
63
return $ key ;
63
64
}
64
65
@@ -101,6 +102,27 @@ protected function getCurrentBinding(string $type, $bindingFallback = null)
101
102
return data_get ($ this ->query ->bindings , "{$ type }. {$ this ->currentBinding }" , $ bindingFallback );
102
103
}
103
104
105
+ protected function getHavingClauses ()
106
+ {
107
+ return Collection::make ($ this ->query ->havings )->reduce (function ($ carry , $ having ) {
108
+ $ value = $ carry ;
109
+ $ value .= $ this ->getHavingClause ($ having );
110
+
111
+ return $ value ;
112
+ });
113
+ }
114
+
115
+ protected function getHavingClause (array $ having ): string
116
+ {
117
+ $ return = '-having ' ;
118
+
119
+ foreach ($ having as $ key => $ value ) {
120
+ $ return .= '_ ' . $ key . '_ ' . str_replace (' ' , '_ ' , $ value );
121
+ }
122
+
123
+ return $ return ;
124
+ }
125
+
104
126
protected function getIdColumn (string $ idColumn ) : string
105
127
{
106
128
return $ idColumn ? "_ {$ idColumn }" : "" ;
0 commit comments