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.

ProductPriceRepository.php 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace domain\Product\ProductPrice\Repository;
  3. use domain\PointSale\PointSale\PointSale;
  4. use domain\Product\Product\Product;
  5. use domain\Product\ProductPrice\Model\ProductPrice;
  6. use domain\User\User\User;
  7. use domain\User\UserGroup\UserGroup;
  8. use domain\_\AbstractRepository;
  9. class ProductPriceRepository extends AbstractRepository
  10. {
  11. protected ProductPriceRepositoryQuery $query;
  12. public function loadDependencies(): void
  13. {
  14. $this->loadQuery(ProductPriceRepositoryQuery::class);
  15. }
  16. /**
  17. * Retourne les options de base nécessaires à la fonction de recherche.
  18. */
  19. public function getDefaultOptionsSearch(): array
  20. {
  21. return [
  22. self::WITH => ['user', 'pointSale', 'userGroup'],
  23. self::JOIN_WITH => ['product'],
  24. self::ORDER_BY => '',
  25. self::ATTRIBUTE_ID_PRODUCER => 'product.id_producer'
  26. ];
  27. }
  28. public function findOneProductPriceById(int $id): ?ProductPrice
  29. {
  30. return $this->createDefaultQuery()
  31. ->filterById($id)
  32. ->findOne();
  33. }
  34. public function findOneProductPriceBy(Product $product, User $user = null, UserGroup $userGroup = null, PointSale $pointSale = null, float $fromQuantity = null)
  35. {
  36. $query = $this->createDefaultQuery()
  37. ->filterByProduct($product);
  38. if($user) {
  39. $query->filterByUser($user);
  40. }
  41. if($userGroup) {
  42. $query->filterByUserGroup($userGroup);
  43. }
  44. if($pointSale) {
  45. $query->filterByPointSale($pointSale);
  46. }
  47. if($fromQuantity) {
  48. $query->filterByFromQuantity($fromQuantity);
  49. }
  50. return $query->findOne();
  51. }
  52. }