The user on my website can have multiple roles. I would like to display products to the user depending on the role he has.
My products table has the field "roles" with string as data type and it can have one or more roles, separated by comma. Example for a product:
product_roles: 'role2, role5, role6'
My variable $rolesLoggedInUser
contains the following array:
$rolesLoggedInUser = ['role3', 'role5', 'role7']
In my repository, I have the following query:
$qb->select('p')
->where('p.roles IN :rolesLoggedInUser')
->setParameter('rolesLoggedInUser', $rolesLoggedInUser)
My goal is that my query returns all data rows in which the field product_roles
contains one or more roles contained in $rolesLoggedInUser
. How do I achieve that?