Good afternoon,
I try to find, from my database specific users with a role which is passed in parameter to the query. However, I have "null" result currently.
The users class is like this example from Symfony Documentation.
This is my CustomerRepository:
class CustomerRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Customer::class);
}
public function findByRole(string $role)
{
return $this->getEntityManager()->createQuery(
'SELECT c
FROM App\Entity\Customer c
WHERE c.roles IN (:role)'
)
->setParameter(':role', $role)
->getResult()
;
}
}
I expect to return an array which contains one or several users who have the role.