We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 867ca27 commit 981463fCopy full SHA for 981463f
app/Repositories/DoctrineUserRepository.php
@@ -128,11 +128,16 @@ public function getByVerificationEmailToken(string $token): ?User
128
]);
129
}
130
131
- public function getByIdWithGroups(int $id): ?User {
132
- return $this->_em->createQuery(
133
- 'SELECT u, g FROM ' .User::class . ' u
134
- LEFT JOIN FETCH u.groups g
135
- WHERE u.id = :id'
136
- )->setParameter('id', $id)->getOneOrNullResult();
+ public function getByIdWithGroups(int $id): ?User
+ {
+ $qb = $this->getEntityManager()->createQueryBuilder();
+
+ $qb->select('DISTINCT u', 'g')
+ ->from(User::class, 'u')
137
+ ->leftJoin('u.groups', 'g')
138
+ ->where('u.id = :id')
139
+ ->setParameter('id', $id);
140
141
+ return $qb->getQuery()->getOneOrNullResult();
142
143
0 commit comments