You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UserPointSaleRepository.php 1.3KB

1 年之前
1 年之前
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace common\logic\PointSale\UserPointSale\Repository;
  3. use common\logic\AbstractRepository;
  4. use common\logic\PointSale\PointSale\Model\PointSale;
  5. use common\logic\PointSale\UserPointSale\Model\UserPointSale;
  6. use common\logic\User\User\Model\User;
  7. class UserPointSaleRepository extends AbstractRepository
  8. {
  9. protected UserPointSaleRepositoryQuery $query;
  10. public function loadDependencies(): void
  11. {
  12. $this->loadQuery(UserPointSaleRepositoryQuery::class);
  13. }
  14. public function getDefaultOptionsSearch(): array
  15. {
  16. return [
  17. self::WITH => [],
  18. self::JOIN_WITH => [],
  19. self::ORDER_BY => '',
  20. self::ATTRIBUTE_ID_PRODUCER => 'point_sale.id_producer'
  21. ] ;
  22. }
  23. public function findUserPointSalesByUser(User $user): array
  24. {
  25. return $this->createDefaultQuery()
  26. ->joinPointSale()
  27. ->filterByUser($user)
  28. ->find();
  29. }
  30. public function findOneUserPointSale(User $user = null, PointSale $pointSale = null)
  31. {
  32. if(!$user || !$pointSale) {
  33. return null;
  34. }
  35. return $this->createDefaultQuery()
  36. ->joinPointSale()
  37. ->filterByUser($user)
  38. ->filterByPointSale($pointSale)
  39. ->findOne();
  40. }
  41. }