@@ -86,41 +86,35 @@ public function list(array $request): Builder
86
86
foreach ($ filters as $ column => $ value ) {
87
87
if (!\is_array ($ value )) {
88
88
$ builder ->where ($ column , '= ' , $ value );
89
-
90
- continue ;
91
- }
92
-
93
- if ($ column === 'withRelations ' ) {
94
- $ builder ->with ($ this ->getValidRelations ($ value ));
95
-
96
- continue ;
97
89
}
90
+ }
98
91
99
- if ($ column === 'withRelationsCount ' ) {
100
- $ validRelations = $ this ->getValidRelations ($ value );
101
- $ builder ->withCount (\array_map (
102
- fn (string $ relationName ): string => $ relationName . ' as ' . $ relationName . static ::COUNT_ALIAS_POSTFIX ,
103
- $ validRelations
104
- ));
105
- $ possibleSortColumns = \array_merge ($ possibleSortColumns , \array_map (
106
- fn (string $ relationName ): string => $ relationName . static ::COUNT_ALIAS_POSTFIX ,
107
- $ validRelations
108
- ));
92
+ if (\is_array ($ request ['withRelations ' ] ?? null )) {
93
+ $ builder ->with ($ this ->getValidRelations ($ request ['withRelations ' ]));
94
+ }
109
95
110
- continue ;
111
- }
96
+ if (\is_array ($ request ['withRelationsCount ' ] ?? null )) {
97
+ $ validRelations = $ this ->getValidRelations ($ request ['withRelationsCount ' ]);
98
+ $ builder ->withCount (\array_map (
99
+ fn (string $ relationName ): string => $ relationName . ' as ' . $ relationName . static ::COUNT_ALIAS_POSTFIX ,
100
+ $ validRelations
101
+ ));
102
+ $ possibleSortColumns = \array_merge ($ possibleSortColumns , \array_map (
103
+ fn (string $ relationName ): string => $ relationName . static ::COUNT_ALIAS_POSTFIX ,
104
+ $ validRelations
105
+ ));
106
+ }
112
107
113
- if ($ column === 'withRelationsExistence ' ) {
114
- $ validRelations = $ this ->getValidRelations ($ value );
115
- $ builder ->withExists (\array_map (
116
- fn (string $ relationName ): string => $ relationName . ' as ' . $ relationName . static ::EXIST_ALIAS_POSTFIX ,
117
- $ validRelations
118
- ));
119
- $ possibleSortColumns = \array_merge ($ possibleSortColumns , \array_map (
120
- fn (string $ relationName ): string => $ relationName . static ::EXIST_ALIAS_POSTFIX ,
121
- $ validRelations
122
- ));
123
- }
108
+ if (\is_array ($ request ['withRelationsExistence ' ] ?? null )) {
109
+ $ validRelations = $ this ->getValidRelations ($ request ['withRelationsExistence ' ]);
110
+ $ builder ->withExists (\array_map (
111
+ fn (string $ relationName ): string => $ relationName . ' as ' . $ relationName . static ::EXIST_ALIAS_POSTFIX ,
112
+ $ validRelations
113
+ ));
114
+ $ possibleSortColumns = \array_merge ($ possibleSortColumns , \array_map (
115
+ fn (string $ relationName ): string => $ relationName . static ::EXIST_ALIAS_POSTFIX ,
116
+ $ validRelations
117
+ ));
124
118
}
125
119
126
120
if ($ this ->shouldIgnoreSort ($ possibleSortColumns )) {
0 commit comments