|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
-
- namespace domain\PointSale\SharedPointSale;
-
- use domain\_\AbstractRepository;
- use domain\PointSale\PointSale\PointSale;
- use domain\Producer\Producer\Producer;
-
- class SharedPointSaleRepository extends AbstractRepository
- {
- protected SharedPointSaleRepositoryQuery $sharedPointSaleRepositoryQuery;
-
- public function loadDependencies(): void
- {
- $this->loadQuery(SharedPointSaleRepositoryQuery::class);
- }
-
- public function getDefaultOptionsSearch(): array
- {
- return [
- self::WITH => [],
- self::JOIN_WITH => ['pointSaleRelation'],
- self::ORDER_BY => '',
- self::ATTRIBUTE_ID_PRODUCER => ''
- ];
- }
-
- public function findOneSharedPointSaleById(int $id)
- {
- return $this->createQuery()
- ->filterById($id)
- ->findOne();
- }
-
- public function findSharedPointsSaleRequestsOfMe()
- {
- return $this->createQuery()
- ->filterByProducerOfPointSale($this->getProducerContext())
- ->filterIsRequest()
- ->find();
- }
-
- public function findSharedPointsSaleRequestsOthers()
- {
- return $this->createQuery()
- ->filterByProducerWithSharing($this->getProducerContext())
- ->filterIsRequest()
- ->find();
- }
-
- public function findSharedPointsSaleConfirmedByPointSale(PointSale $pointSale, Producer $producerWithSharing = null)
- {
- $query = $this->createQuery()
- ->filterByPointSale($pointSale)
- ->filterIsConfirmed();
-
- if($producerWithSharing) {
- $query->filterByProducerWithSharing($producerWithSharing);
- }
-
- return $query->find();
- }
-
- public function findOneSharedPointsSaleConfirmed(PointSale $pointSale, Producer $producer)
- {
- return $this->createQuery()
- ->filterByPointSale($pointSale)
- ->filterByProducer($producer)
- ->filterIsConfirmed()
- ->findOne();
- }
-
- public function findSharedPointSaleRequestByPointSale(PointSale $pointSale, Producer $producerWithSharing = null)
- {
- $query = $this->createQuery()
- ->filterByPointSale($pointSale)
- ->filterIsRequest();
-
- if($producerWithSharing) {
- $query->filterByProducerWithSharing($producerWithSharing);
- }
-
- return $query->find();
- }
- }
|