Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

UserPointSaleRepository.php 1.2KB

1 rok temu
1 rok temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace common\logic\PointSale\UserPointSale\Repository;
  3. use common\logic\AbstractRepository;
  4. use common\logic\PointSale\PointSale\Model\PointSale;
  5. use common\logic\PointSale\UserPointSale\Model\UserPointSale;
  6. use common\logic\User\User\Model\User;
  7. class UserPointSaleRepository extends AbstractRepository
  8. {
  9. protected UserPointSaleRepositoryQuery $query;
  10. public function loadDependencies(): void
  11. {
  12. $this->query = $this->loadService(UserPointSaleRepositoryQuery::class);
  13. }
  14. public function getDefaultOptionsSearch(): array
  15. {
  16. return [
  17. 'with' => [],
  18. 'join_with' => [],
  19. 'orderby' => '',
  20. 'attribute_id_producer' => ''
  21. ] ;
  22. }
  23. public function findUserPointSalesByUser(User $user): array
  24. {
  25. return UserPointSale::searchAll([
  26. 'id_user' => $user->id
  27. ]);
  28. }
  29. public function findOneUserPointSale(User $user = null, PointSale $pointSale = null)
  30. {
  31. if(!$user || !$pointSale) {
  32. return null;
  33. }
  34. return UserPointSale::find()
  35. ->where([
  36. 'id_user' => $user->id,
  37. 'id_point_sale' => $pointSale->id
  38. ])->one();
  39. }
  40. }