|
- <?php
-
- namespace domain\Distribution\PointSaleDistribution;
-
- use domain\Distribution\Distribution\Distribution;
- use domain\PointSale\PointSale\PointSale;
- use domain\_\AbstractRepository;
-
- class PointSaleDistributionRepository extends AbstractRepository
- {
- protected PointSaleDistributionRepositoryQuery $query;
-
- public function loadDependencies(): void
- {
- $this->loadQuery(PointSaleDistributionRepositoryQuery::class);
- }
-
- public function getDefaultOptionsSearch(): array
- {
- return [
- self::WITH => ['distribution', 'pointSale'],
- self::JOIN_WITH => [],
- self::ORDER_BY => '',
- self::ATTRIBUTE_ID_PRODUCER => ''
- ];
- }
-
- public function findOnePointSaleDistribution(Distribution $distribution, PointSale $pointSale, bool $delivery = null): ?PointSaleDistribution
- {
- $query = $this->createDefaultQuery()
- ->filterByDistribution($distribution)
- ->filterByPointSale($pointSale);
-
- if(!is_null($delivery)) {
- $query->filterIsDelivery($delivery);
- }
-
- return $query->findOne();
- }
-
- public function findPointSaleDistributionsByDistribution(Distribution $distribution): array
- {
- return $this->createDefaultQuery()
- ->filterByDistribution($distribution)
- ->find();
- }
-
- public function countPointSaleDistributionsByDistribution(Distribution $distribution): int
- {
- return $this->createDefaultQuery()
- ->filterByDistribution($distribution)
- ->count();
- }
- }
|