Shoping.php 1.3 KB

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