StoreProductAttrDao.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\dao\product\sku;
  12. use app\dao\BaseDao;
  13. use app\model\product\sku\StoreProductAttr;
  14. /**
  15. * Class StoreProductAttrDao
  16. * @package app\dao\product\sku
  17. */
  18. class StoreProductAttrDao extends BaseDao
  19. {
  20. /**
  21. * 设置模型
  22. * @return string
  23. */
  24. protected function setModel(): string
  25. {
  26. return StoreProductAttr::class;
  27. }
  28. /**
  29. * 删除sku
  30. * @param int $id
  31. * @param int $type
  32. * @return bool
  33. * @throws \Exception
  34. */
  35. public function del(int $id, int $type)
  36. {
  37. return $this->search(['product_id' => $id, 'type' => $type])->delete();
  38. }
  39. /**
  40. * 保存sku
  41. * @param array $data
  42. * @return mixed|\think\Collection
  43. * @throws \Exception
  44. */
  45. public function saveAll(array $data)
  46. {
  47. return $this->getModel()->saveAll($data);
  48. }
  49. /**
  50. * 获取商品sku
  51. * @param array $where
  52. * @return array
  53. * @throws \think\db\exception\DataNotFoundException
  54. * @throws \think\db\exception\DbException
  55. * @throws \think\db\exception\ModelNotFoundException
  56. */
  57. public function getProductAttr(array $where)
  58. {
  59. return $this->search($where)->select()->toArray();
  60. }
  61. }