Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

SharedPointSaleRepositoryQuery.php 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace domain\PointSale\SharedPointSale;
  3. use domain\_\AbstractRepositoryQuery;
  4. use domain\_\StatusInterface;
  5. use domain\PointSale\PointSale\PointSale;
  6. use domain\Producer\Producer\Producer;
  7. class SharedPointSaleRepositoryQuery extends AbstractRepositoryQuery
  8. {
  9. protected SharedPointSaleDefinition $sharedPointSaleDefinition;
  10. public function loadDependencies(): void
  11. {
  12. $this->loadDefinition(SharedPointSaleDefinition::class);
  13. }
  14. public function filterIsStatusOnline()
  15. {
  16. $this->andWhere(['shared_point_sale.status' => StatusInterface::STATUS_ONLINE]);
  17. return $this;
  18. }
  19. public function filterByProducerOfPointSale(Producer $producer): self
  20. {
  21. $this->andWhere(['point_sale.id_producer' => $producer->id]);
  22. return $this;
  23. }
  24. public function filterByProducerWithSharing(Producer $producer): self
  25. {
  26. $this->andWhere(['id_producer_with_sharing' => $producer->id]);
  27. return $this;
  28. }
  29. public function filterByPointSale(PointSale $pointSale): self
  30. {
  31. $this->andWhere('id_point_sale = :id_point_sale OR id_point_sale_with_sharing = :id_point_sale')
  32. ->addParams(['id_point_sale' => $pointSale->id]);
  33. return $this;
  34. }
  35. public function filterByProducer(Producer $producer): self
  36. {
  37. $this->andWhere('point_sale.id_producer = :id_producer OR id_producer_with_sharing = :id_producer')
  38. ->addParams(['id_producer' => $producer->id]);
  39. return $this;
  40. }
  41. public function filterIsRequest()
  42. {
  43. $this->filterIsPointSaleWithSharingIsNull()
  44. ->filterIsStatusOnline();
  45. return $this;
  46. }
  47. public function filterIsConfirmed()
  48. {
  49. $this->filterIsStatusOnline();
  50. $this->andWhere('id_point_sale_with_sharing IS NOT NULL AND confirmed_at IS NOT NULL AND declined_at IS NULL');
  51. return $this;
  52. }
  53. public function filterIsPointSaleWithSharingIsNull(): self
  54. {
  55. $this->andWhere('id_point_sale_with_sharing IS NULL');
  56. return $this;
  57. }
  58. }