setBaseQuery($this->alias, [ ['goods', 'goods_id'], ['user', 'user_id'], ]); // 检索查询条件 if (!empty($search)) { $this->where(function ($query) use ($search) { $query->whereOr('goods.goods_name', 'like', "%{$search}%"); $query->whereOr('user.nickName', 'like', "%{$search}%"); }); } // 获取活动列表 $list = $this->with(['user']) ->where("{$this->alias}.is_delete", '=', 0) ->order(["{$this->alias}.create_time" => 'desc']) ->paginate(15, false, [ 'query' => \request()->request() ]); if (!$list->isEmpty()) { // 设置商品数据 $list = GoodsService::setGoodsData($list); } return $list; } /** * 软删除 * @return false|int */ public function setDelete() { return $this->allowField(true)->save(['is_delete' => 1]); } }