StoreProductVirtualDao.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\dao\product\sku;
  3. use app\dao\BaseDao;
  4. use app\model\product\sku\StoreProductVirtual;
  5. class StoreProductVirtualDao extends BaseDao
  6. {
  7. /**
  8. * 设置模型
  9. * @return string
  10. */
  11. protected function setModel(): string
  12. {
  13. return StoreProductVirtual::class;
  14. }
  15. /**
  16. * 获取列表
  17. * @param array $where
  18. * @param string $field
  19. * @param int $page
  20. * @param int $limit
  21. * @return array
  22. * @throws \think\db\exception\DataNotFoundException
  23. * @throws \think\db\exception\DbException
  24. * @throws \think\db\exception\ModelNotFoundException
  25. */
  26. public function getList(array $where, string $field = '*', int $page = 0, int $limit = 0)
  27. {
  28. return $this->search($where)->field($field)
  29. ->when($page && $limit, function ($query) use ($page, $limit) {
  30. $query->page($page, $limit);
  31. })->when(!$page && $limit, function ($query) use ($limit) {
  32. $query->limit($limit);
  33. })->order('id asc')->select()->toArray();
  34. }
  35. }