|
- <?php
-
- namespace Lc\CaracoleBundle\Repository\User;
-
- use App\Entity\Merchant\Merchant;
- use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
- use Lc\SovBundle\Repository\User\UserRepositoryQuery as SovUserRepositoryQuery;
-
- class UserRepositoryQuery extends SovUserRepositoryQuery
- {
- use MerchantRepositoryQueryTrait;
-
- protected $isJoinUserMerchants = false;
-
- public function joinUserMerchants(): self
- {
- if (!$this->isJoinUserMerchants) {
- $this->isJoinUserMerchants = true;
-
- return $this
- ->innerJoin('.userMerchants', 'um');
- }
- return $this;
- }
-
- public function filterMerchantIsActive(): self
- {
- $this->joinUserMerchants();
- return $this
- ->andWhere('um.active = 1');
- }
-
- public function filterByMerchant(Merchant $merchant): self
- {
- $this->joinUserMerchants();
- return $this
- ->andWhere('um.merchant = :merchant')
- ->setParameter('merchant', $merchant);
- }
- }
|