gogs 2 месяцев назад
Родитель
Сommit
e9d4b9e829
1 измененных файлов с 4 добавлено и 3 удалено
  1. 4 3
      app/Service/StatisticService.php

+ 4 - 3
app/Service/StatisticService.php

@@ -637,8 +637,8 @@ class StatisticService extends Service
             }
 
         }
-//        dd($type_list);
-        $type_list = collect($type_list)->sortBy('sort')->all();
+        // 使用 values() 丢弃原始键名,重新从 0 开始建立索引
+        $type_list = collect($type_list)->sortBy('sort')->values()->all();
         // 4. 重置数组索引并返回
         return [$item_key_list,$type_list];
     }
@@ -769,7 +769,8 @@ class StatisticService extends Service
                 ];
             }
         }
-        $type_list = collect($type_list)->sortBy('sort')->all();
+        // 使用 values() 丢弃原始键名,重新从 0 开始建立索引
+        $type_list = collect($type_list)->sortBy('sort')->values()->all();
         // 4. 重置数组索引并返回
         return [$list,$type_list];
     }