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 a8e26e7Copy full SHA for a8e26e7
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
+ {
+ $dql = 'SELECT DISTINCT u
+ FROM ' . User::class . ' u
+ LEFT JOIN FETCH u.groups g
+ WHERE u.id = :id';
137
+
138
+ return $this->getEntityManager()
139
+ ->createQuery($dql)
140
+ ->setParameter('id', $id)
141
+ ->getOneOrNullResult();
142
143
0 commit comments