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.

38 lines
1.0KB

  1. <?php
  2. namespace common\logic\PointSale\UserPointSale\Repository;
  3. use common\logic\AbstractRepositoryQuery;
  4. use common\logic\PointSale\PointSale\Model\PointSale;
  5. use common\logic\PointSale\UserPointSale\Model\UserPointSale;
  6. use common\logic\PointSale\UserPointSale\Service\UserPointSaleDefinition;
  7. use common\logic\User\User\Model\User;
  8. use yii\db\ActiveQuery;
  9. class UserPointSaleRepositoryQuery extends AbstractRepositoryQuery
  10. {
  11. protected UserPointSaleDefinition $definition;
  12. public function loadDependencies(): void
  13. {
  14. $this->loadDefinition(UserPointSaleDefinition::class);
  15. }
  16. public function joinPointSale(): self
  17. {
  18. $this->innerJoinWith('pointSale', true);
  19. return $this;
  20. }
  21. public function filterByUser(User $user): self
  22. {
  23. $this->andWhere(['user_point_sale.id_user' => $user->id]);
  24. return $this;
  25. }
  26. public function filterByPointSale(PointSale $pointSale): self
  27. {
  28. $this->andWhere(['id_point_sale' => $pointSale->id]);
  29. return $this;
  30. }
  31. }