From 47afe5b6a8617e0cd6f34940d9531629997d167d Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Fri, 17 Mar 2023 22:15:56 +0800 Subject: [PATCH] store --- app/Endpoint/Api/Http/Controllers/StoreController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Endpoint/Api/Http/Controllers/StoreController.php b/app/Endpoint/Api/Http/Controllers/StoreController.php index 5850dcf6..084cd3df 100644 --- a/app/Endpoint/Api/Http/Controllers/StoreController.php +++ b/app/Endpoint/Api/Http/Controllers/StoreController.php @@ -12,6 +12,7 @@ use App\Endpoint\Api\Http\Resources\ProductFeatureResource; use App\Events\ProductSkuViewed; use App\Models\Store\Desk; use App\Endpoint\Api\Http\Resources\DeskResource; +use App\Exceptions\BizException; class StoreController extends Controller { @@ -67,8 +68,8 @@ class StoreController extends Controller $spu = $store->productSpus()->with(['specs', 'features'])->findOrFail($id); $sku = $store->productSkus() - ->where('product_spu_id', $spu->id) - ->when($request->filled('sku_id'), fn($q) => $q->where('product_sku_id', $request->input('sku_id'))) + ->wherePivot('product_spu_id', $spu->id) + ->when($request->filled('sku_id'), fn($q) => $q->wherePivot('product_sku_id', $request->input('sku_id'))) ->first(); if (!$sku) { throw new BizException('商品sku未上架');