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.

SharedPointSaleRepository.php 2.3KB

5 kuukautta sitten
5 kuukautta sitten
5 kuukautta sitten
5 kuukautta sitten
5 kuukautta sitten
5 kuukautta sitten
5 kuukautta sitten
5 kuukautta sitten
5 kuukautta sitten
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace domain\PointSale\SharedPointSale;
  3. use domain\_\AbstractRepository;
  4. use domain\PointSale\PointSale\PointSale;
  5. use domain\Producer\Producer\Producer;
  6. class SharedPointSaleRepository extends AbstractRepository
  7. {
  8. protected SharedPointSaleRepositoryQuery $sharedPointSaleRepositoryQuery;
  9. public function loadDependencies(): void
  10. {
  11. $this->loadQuery(SharedPointSaleRepositoryQuery::class);
  12. }
  13. public function getDefaultOptionsSearch(): array
  14. {
  15. return [
  16. self::WITH => [],
  17. self::JOIN_WITH => ['pointSaleRelation'],
  18. self::ORDER_BY => '',
  19. self::ATTRIBUTE_ID_PRODUCER => ''
  20. ];
  21. }
  22. public function findOneSharedPointSaleById(int $id)
  23. {
  24. return $this->createQuery()
  25. ->filterById($id)
  26. ->findOne();
  27. }
  28. public function findSharedPointsSaleRequestsOfMe()
  29. {
  30. return $this->createQuery()
  31. ->filterByProducerOfPointSale($this->getProducerContext())
  32. ->filterIsRequest()
  33. ->find();
  34. }
  35. public function findSharedPointsSaleRequestsOthers()
  36. {
  37. return $this->createQuery()
  38. ->filterByProducerWithSharing($this->getProducerContext())
  39. ->filterIsRequest()
  40. ->find();
  41. }
  42. public function findSharedPointsSaleConfirmedByPointSale(PointSale $pointSale, Producer $producerWithSharing = null)
  43. {
  44. $query = $this->createQuery()
  45. ->filterByPointSale($pointSale)
  46. ->filterIsConfirmed();
  47. if($producerWithSharing) {
  48. $query->filterByProducerWithSharing($producerWithSharing);
  49. }
  50. return $query->find();
  51. }
  52. public function findOneSharedPointsSaleConfirmed(PointSale $pointSale, Producer $producer)
  53. {
  54. return $this->createQuery()
  55. ->filterByPointSale($pointSale)
  56. ->filterByProducer($producer)
  57. ->filterIsConfirmed()
  58. ->findOne();
  59. }
  60. public function findSharedPointSaleRequestByPointSale(PointSale $pointSale, Producer $producerWithSharing = null)
  61. {
  62. $query = $this->createQuery()
  63. ->filterByPointSale($pointSale)
  64. ->filterIsRequest();
  65. if($producerWithSharing) {
  66. $query->filterByProducerWithSharing($producerWithSharing);
  67. }
  68. return $query->find();
  69. }
  70. }