From fbe51c5e8e0782ffa58b988d392417d477d5f19a Mon Sep 17 00:00:00 2001 From: liapples Date: Fri, 17 Sep 2021 11:14:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=BC=94=E7=A4=BA=E4=BA=A7=E5=93=81=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0status=3Don=5Fsale?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/AgentProductController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/AgentProductController.php b/app/Http/Controllers/Api/AgentProductController.php index 72eeaf4..1e97b28 100644 --- a/app/Http/Controllers/Api/AgentProductController.php +++ b/app/Http/Controllers/Api/AgentProductController.php @@ -142,7 +142,9 @@ class AgentProductController extends Controller //如果是新入驻代理商没有数据,且没有删除过的数据,则显示最早的几条 if ($list->isEmpty()) { if (AgentProduct::list($this->agent_id)->withTrashed()->count() === 0 && request('page', 1) <= 2) { //只获取2页数据 - $list = AgentProduct::list($this->agent_id)->orWhereRaw(1)->orderBy('id')->simplePaginate(); + $list = AgentProduct::list($this->agent_id)->orWhere(function ($query) { + $query->where('status', ProductStatus::ON_SALE); + })->orderBy('id')->simplePaginate(); } else { return $list; //因为只获取2页数据,不return可能会导入下面的代码出错 }