From a797412fd7c06bc8f325727b04072b942d92b662 Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Wed, 15 Feb 2023 17:00:56 +0800 Subject: [PATCH] 1 --- .../Api/Http/Controllers/StoreController.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Endpoint/Api/Http/Controllers/StoreController.php b/app/Endpoint/Api/Http/Controllers/StoreController.php index fb88c4ac..b27c8772 100644 --- a/app/Endpoint/Api/Http/Controllers/StoreController.php +++ b/app/Endpoint/Api/Http/Controllers/StoreController.php @@ -42,11 +42,15 @@ class StoreController extends Controller $input['sort'] = '-id'; } - $spuIds = StoreProductSku::where('store_id', $store->id)->where('status', 1)->pluck('product_spu_id')->toArray(); - $spuIds = array_unique($spuIds); - $spuIds = array_values($spuIds); + // $spuIds = StoreProductSku::where('store_id', $store->id)->where('status', 1)->pluck('product_spu_id')->toArray(); + // $spuIds = array_unique($spuIds); + // $spuIds = array_values($spuIds); - $list = ProductSpu::with(['specs'])->filter($input)->whereIn('id', $spuIds)->simplePaginate(Paginator::resolvePerPage('per_page', 20, 50)); + $list = $store->productSpus() + ->with(['specs']) + ->filter($input) + ->wherePivot('status', 1) + ->simplePaginate(Paginator::resolvePerPage('per_page', 20, 50)); return StoreProductSpuResource::collection($list); }