getOneData($where, 'id'); if (!empty($id)) { $data['id'] = $id; } return $this->dataUpdate($data); } /** * 获取我的浏览列表(带分页) * @date 2022-11-30 */ public function listMyBrowseWithPage($where, $page, $field = '*', $order = '', $per_page_number = 10) { // 默认排序 if (empty($order)) { $order = 'id desc'; } // $dataList = $this->with(['mallProduct'])->field($field)->where($where)->order($order) ->paginate(['list_rows' => $per_page_number, 'page' => $page], false)->each(function ($item) { $item['browse_date_text'] = $item->browse_date_text; unset($item['mallProduct']); }); return $dataList; } /** * 远程一对多关联产品 * @date 2021-03-01 */ // public function mallProduct() // { // //MallProductAttach.product_id = mallProduct.id MallAttach.id = MallProductAttach.attach_id // return $this->hasManyThrough('MallProduct', 'MallBrowse', 'browse_date', 'browse_date', 'id', 'product_id'); // } /** * 当天浏览记录 * @date 2021-03-01 */ // public function mallBrowse() // { // return $this->hasMany('MallBrowse', 'browse_date', 'browse_date'); // } /** * 一对一关联产品 * @date 2021-03-01 */ public function mallProduct() { return $this->hasOne('MallProduct', 'id', 'product_id')->bind([ 'product_name' => 'name', 'product_price' => 'price_min', 'product_cover_img' => 'cover_img' ])->removeOption('soft_delete'); } }