How to render elements in a view based on ManyToMany relationship

users, roles and users_roles and created phalcon project by using Phalcon tools as well as generated models, controllers and views (php) by scaffolding tables with Phalcon tools.
I have established working many-to-many relationship between tables users and roles via intermediate table users_roles.

My intention is to show search results in 'user' search view in this manner - generated table shold be like this

TABLE:

USER ROLES
user1 role1,role2,role3
user2 role2
user3 role1,role3

Many-to-many relationship in Users model is :

public function initialize()
{
$this->hasManyToMany('id',
'UsersRoles',
'user_id','role_id',
'Roles',
'id',
['alias' => 'UserRoles']); <--- alias is a must. it wil be used later as 'userRoles' property in foreach...
}

Not to be contrary, but getRelated() isn't necessary. You absolutely can use the alias name as a magic getter. I think the issue is the alias is set up as UserRoles (capital "U"), but you're referencing userRoles (lower "U"). Case matters, so capitalize properly and it should work.

After a while the whole system broke down. Frankel wasn't paying any attention; he wasn't supervising anybody. The system was going very, very slowly - while he was sitting in a room figuring out how to make one tabulator automatically print arc-tangent X,