|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
-
- namespace Lc\SovBundle\Repository\User;
-
- use App\Entity\Merchant\Merchant;
- use App\Entity\Newsletter\Newsletter;
- use Knp\Component\Pager\PaginatorInterface;
- use Lc\SovBundle\Repository\AbstractRepositoryQuery;
-
- class UserRepositoryQuery extends AbstractRepositoryQuery implements UserRepositoryQueryInterface
- {
- public function __construct(UserRepository $repository, PaginatorInterface $paginator)
- {
- parent::__construct($repository, 'user', $paginator);
- }
-
- protected $isJoinGroupUsers = false;
-
- public function joinGroupUsers($addSelect = true): self
- {
- if (!$this->isJoinGroupUsers) {
- $this->isJoinGroupUsers = true;
-
- $this->leftJoin('.groupUsers', 'groupUsers');
- if($addSelect){
- $this->addSelect('groupUsers');
- }
- }
- return $this;
- }
-
-
- public function filterByNewsletter(Newsletter $newsletter): self
- {
- return $this
- ->andWhere(':newsletter MEMBER OF .newsletters')
- ->setParameter('newsletter', $newsletter->getId());
- }
-
- public function filterByRole(string $role): self
- {
- return $this
- ->andWhere('.roles LIKE :roles')
- ->setParameter('roles', '%"' . $role . '"%');
- }
-
- public function filterByTicketTypeNotification(string $ticketType): self
- {
- return $this
- ->andWhere('.ticketTypesNotification LIKE :ticketType')
- ->setParameter('ticketType', '%"' . $ticketType . '"%');
- }
-
- public function filterByEmail(string $email): self
- {
- return $this
- ->andWhere('.email LIKE :email')
- ->setParameter('email', $email);
- }
-
- public function filterByTerm(string $term): self
- {
- return $this
- ->andWhere('.email LIKE :term OR .firstname LIKE :term OR .lastname LIKE :term')
- ->setParameter('term', '%'.$term.'%');
- }
-
- }
|