黄宗昌 hace 2 años
padre
commit
1909003199
Se han modificado 1 ficheros con 2 adiciones y 7 borrados
  1. 2 7
      app/Http/Controllers/V1/ProductController.php

+ 2 - 7
app/Http/Controllers/V1/ProductController.php

xqd xqd
@@ -174,7 +174,7 @@ class ProductController extends Controller
     public function productList(Request $request){
         $limit = $request->get('limit',10);
         $type = $request->get('type');
-
+        $go = $request->get('go');
         $query = Product::query()
             ->with('user:id,name,nickname,avatar,company_name,company_card_color,production_project');
         if(!empty($type)){
@@ -183,13 +183,8 @@ class ProductController extends Controller
         }
         $list = $query->where('status',1)
             ->paginate($limit);
-        $data = [];
-        foreach ($list as $v){
-            $data[] = [$v->toArray()];
-        }
-
         $data = [
-            'items' => $data,
+            'items' => array_chunk($list->items(),$go) ,
             'total' => $list->total(),   // 总数
             'pageSize' => $list->perPage(), // 每页数据
             'totalPage' => $list->lastPage(),// 总页数