Ken 4 天之前
父节点
当前提交
edc1728379
共有 1 个文件被更改,包括 12 次插入4 次删除
  1. 12 4
      app/Services/BackflowService.php

+ 12 - 4
app/Services/BackflowService.php

@@ -82,9 +82,17 @@ class BackflowService extends BaseService
                 $query1->where('username', $username);
             });
         }
-        $count = $query->count();
-        $query->with(['user'])->orderByDesc('date')->orderBy('status');
-        $list = $query->forPage($search['page'], $search['limit'])->get()->toArray();
-        return ['total' => $count, 'data' => $list];
+
+        $paginator = $query
+            ->with(['user'])->orderByDesc('date')->orderBy('status')
+
+
+            ->paginate($search['limit']);
+
+//        $count = $query->count();
+//        $query->with(['user'])->orderByDesc('date')->orderBy('status');
+//        $list = $query->forPage($search['page'], $search['limit'])->get()->toArray();
+//        return ['total' => $count, 'data' => $list];
+        return ['total' => $paginator->total(), 'data' => $paginator->items()];
     }
 }