Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

UserMerchantStore.php 1.7KB

3 år sedan
3 år sedan
3 år sedan
3 år sedan
3 år sedan
3 år sedan
3 år sedan
3 år sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\User;
  3. use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
  4. use Lc\CaracoleBundle\Model\User\UserMerchantInterface;
  5. use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
  6. use Lc\CaracoleBundle\Solver\User\UserMerchantSolver;
  7. use Lc\SovBundle\Model\User\UserInterface;
  8. use Lc\SovBundle\Repository\AbstractStore;
  9. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  10. class UserMerchantStore extends AbstractStore
  11. {
  12. use MerchantStoreTrait;
  13. protected UserMerchantRepositoryQuery $query;
  14. protected UserMerchantSolver $userMerchantSolver;
  15. public function __construct(UserMerchantRepositoryQuery $query, UserMerchantSolver $userMerchantSolver)
  16. {
  17. $this->query = $query;
  18. $this->userMerchantSolver = $userMerchantSolver;
  19. }
  20. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  21. {
  22. $query->orderBy('id');
  23. return $query;
  24. }
  25. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  26. {
  27. $query->filterByMerchant($this->merchant);
  28. return $query;
  29. }
  30. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  31. {
  32. return $query;
  33. }
  34. // getUserMerchant
  35. public function getOneByUser(UserInterface $user, $query = null): UserMerchantInterface
  36. {
  37. $query = $this->createDefaultQuery($query);
  38. $query->filterByUser($user);
  39. return $query->findOne();
  40. }
  41. public function isCreditActiveByUser(UserInterface $user, $query = null): bool
  42. {
  43. $userMerchant = $this->getOneByUser($user, $query);
  44. return $this->userMerchantSolver->isCreditActive($userMerchant);
  45. }
  46. }