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.

42 satır
1.1KB

  1. <?php
  2. namespace domain\Product\ProductAccessory;
  3. use domain\_\AbstractRepository;
  4. use domain\Product\Accessory\Accessory;
  5. use domain\Product\Product\Product;
  6. class ProductAccessoryRepository extends AbstractRepository
  7. {
  8. protected ProductAccessoryRepositoryQuery $query;
  9. public function loadDependencies(): void
  10. {
  11. $this->loadQuery(ProductAccessoryRepositoryQuery::class);
  12. }
  13. public function getDefaultOptionsSearch(): array
  14. {
  15. return [
  16. self::WITH => [],
  17. self::JOIN_WITH => ['accessoryRelation'],
  18. self::ORDER_BY => 'accessory.name ASC',
  19. self::ATTRIBUTE_ID_PRODUCER => ''
  20. ];
  21. }
  22. public function findOneProductAccessory(Product $product, Accessory $accessory): ?ProductAccessory
  23. {
  24. return $this->createDefaultQuery()
  25. ->filterByProduct($product)
  26. ->filterByAccessory($accessory)
  27. ->findOne();
  28. }
  29. public function findProductAccessoriesByAccessory(Accessory $accessory): array
  30. {
  31. return $this->createDefaultQuery()
  32. ->filterByAccessory($accessory)
  33. ->find();
  34. }
  35. }