Browse Source

orWhere

master
李可松 4 years ago
parent
commit
9052729bef
  1. 4
      app/Http/Controllers/Api/AgentProductController.php

4
app/Http/Controllers/Api/AgentProductController.php

@ -142,9 +142,7 @@ class AgentProductController extends Controller
//如果是新入驻代理商没有数据,且没有删除过的数据,则显示最早的几条 //如果是新入驻代理商没有数据,且没有删除过的数据,则显示最早的几条
if ($list->isEmpty()) { if ($list->isEmpty()) {
if (AgentProduct::list($this->agent_id)->withTrashed()->count() === 0 && request('page', 1) <= 2) { //只获取2页数据 if (AgentProduct::list($this->agent_id)->withTrashed()->count() === 0 && request('page', 1) <= 2) { //只获取2页数据
$list = AgentProduct::list($this->agent_id)->orWhere(function ($query) {
$query->where([['status', '=', ProductStatus::ON_SALE], ['price', '>', 100]]);
})->orderBy('id')->simplePaginate();
$list = AgentProduct::list($this->agent_id)->orWhere([['status', '=', ProductStatus::ON_SALE], ['price', '>', 100]])->orderBy('id')->simplePaginate();
} else { } else {
return $list; //因为只获取2页数据,不return可能会导入下面的代码出错 return $list; //因为只获取2页数据,不return可能会导入下面的代码出错
} }

Loading…
Cancel
Save