@@ -19,13 +19,17 @@ public function __construct(
1919
2020 public function apply ($ query , array $ filters ): void
2121 {
22- $ this ->applyGroup ($ query , $ filters , 'and ' , []);
22+ $ this ->applyGroup ($ query , $ filters , 'and ' , [], $ this -> resolveAvailableFilters () );
2323 }
2424
25- private function applyGroup ($ query , array $ filters , string $ boolean , array $ path ): void
26- {
25+ private function applyGroup (
26+ $ query ,
27+ array $ filters ,
28+ string $ boolean ,
29+ array $ path ,
30+ array $ availableFilters ,
31+ ): void {
2732 $ clauses = [];
28- $ availableFilters = $ this ->resolveAvailableFilters ();
2933
3034 foreach ($ filters as $ key => $ value ) {
3135 $ keyPath = [...$ path , $ key ];
@@ -38,7 +42,13 @@ private function applyGroup($query, array $filters, string $boolean, array $path
3842 throw $ this ->badRequest (new InvalidFilterStructureException (), $ keyPath );
3943 }
4044
41- $ clauses [] = fn ($ query ) => $ this ->applyGroup ($ query , $ value , $ key , $ keyPath );
45+ $ clauses [] = fn ($ query ) => $ this ->applyGroup (
46+ $ query ,
47+ $ value ,
48+ $ key ,
49+ $ keyPath ,
50+ $ availableFilters ,
51+ );
4252
4353 continue ;
4454 }
@@ -48,7 +58,13 @@ private function applyGroup($query, array $filters, string $boolean, array $path
4858 throw $ this ->badRequest (new InvalidFilterStructureException (), $ keyPath );
4959 }
5060
51- $ clauses [] = fn ($ query ) => $ this ->applyGroup ($ query , $ value , 'and ' , $ keyPath );
61+ $ clauses [] = fn ($ query ) => $ this ->applyGroup (
62+ $ query ,
63+ $ value ,
64+ 'and ' ,
65+ $ keyPath ,
66+ $ availableFilters ,
67+ );
5268
5369 continue ;
5470 }
0 commit comments