Shoping.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace app\store\model\wow;
  3. use app\common\model\wow\Shoping as ShopingModel;
  4. /**
  5. * 好物圈商品收藏记录模型
  6. * Class Shoping
  7. * @package app\store\model\wow
  8. */
  9. class Shoping extends ShopingModel
  10. {
  11. /**
  12. * 获取列表
  13. * @param string $search
  14. * @return \think\Paginator
  15. * @throws \think\exception\DbException
  16. */
  17. public function getList($search = '')
  18. {
  19. $this->setBaseQuery($this->alias, [
  20. ['goods', 'goods_id'],
  21. ['user', 'user_id'],
  22. ]);
  23. // 检索查询条件
  24. if (!empty($search)) {
  25. $this->where(function ($query) use ($search) {
  26. $query->whereOr('goods.goods_name', 'like', "%{$search}%")
  27. ->whereOr('user.nickName', 'like', "%{$search}%");
  28. });
  29. }
  30. // 返回列表数据
  31. return $this->with(['goods.image.file', 'user'])
  32. ->where("{$this->alias}.is_delete", '=', 0)
  33. ->order(["{$this->alias}.create_time" => 'desc'])
  34. ->paginate(15, false, [
  35. 'query' => request()->request()
  36. ]);
  37. }
  38. }