@@ -21,24 +21,29 @@ public function toArray(Request $request): array
2121 'id ' => $ this ->id ,
2222 'name ' => $ this ->displaySectionName ,
2323 'categories ' => CategoryResource::collection ($ this ->whenLoaded ('categories ' )),
24+ 'tags ' => TagResource::collection ($ this ->whenLoaded ('tags ' )),
2425 ];
25- $ subCategories = [];
26- $ lang = get_langfolder_cookie ();
27- $ fields = array_keys (SearchBox::$ taxonomies );
28- if (!empty ($ searchBox ->extra ['taxonomy_labels ' ])) {
29- $ fields = array_column ($ searchBox ->extra ['taxonomy_labels ' ], 'torrent_field ' );
30- }
31- foreach ($ fields as $ field ) {
32- $ relationName = "taxonomy_ $ field " ;
33- if ($ searchBox ->relationLoaded ($ relationName )) {
34- $ subCategories [] = [
35- 'field ' => $ field ,
36- 'label ' => $ item ['display_text ' ][$ lang ] ?? (nexus_trans ("searchbox.sub_category_ {$ field }_label " ) ?: ucfirst ($ field )),
37- 'data ' => MediaResource::collection ($ searchBox ->{$ relationName }),
38- ];
26+ if ($ searchBox ->showsubcat ) {
27+ $ subCategories = [];
28+ $ lang = get_langfolder_cookie ();
29+ $ fields = array_keys (SearchBox::$ taxonomies );
30+ if (!empty ($ searchBox ->extra ['taxonomy_labels ' ])) {
31+ $ fields = array_column ($ searchBox ->extra ['taxonomy_labels ' ], 'torrent_field ' );
32+ }
33+ foreach ($ fields as $ field ) {
34+ $ relationName = "taxonomy_ $ field " ;
35+ if ($ searchBox ->relationLoaded ($ relationName )) {
36+ $ subCategories [] = [
37+ 'field ' => $ field ,
38+ 'label ' => $ item ['display_text ' ][$ lang ] ?? (nexus_trans ("searchbox.sub_category_ {$ field }_label " ) ?: ucfirst ($ field )),
39+ 'data ' => MediaResource::collection ($ searchBox ->{$ relationName }),
40+ ];
41+ }
42+ }
43+ if (!empty ($ subCategories )) {
44+ $ out ['sub_categories ' ] = $ subCategories ;
3945 }
4046 }
41- $ out ['sub_categories ' ] = $ this ->when ($ this ->showsubcat , $ subCategories );
4247 return $ out ;
4348 }
4449}
0 commit comments