Hello i am pretty new to phalcon and have not a question about the models. I have the following tables:
User Table:
+----+-----+
| id | name
+----+-----+
| 1 | User1
| 2 | User2
| 3 | User3
+----+-----+
UserRole Table:
+----+-----+
| userid | roleid
+----+-----+
| 1 | 1
| 1 | 2
| 2 | 1
| 3 | 2
+----+-----+
Roles Table:
+----+-----+
| id | name
+----+-----+
| 1 | Role1
| 2 | Role2
+----+-----+
Now i can collect all Roles of the User like this. Its working.
$res =$user->findFirst()->getUserRoles();
foreach($res as $userRole){
var_dump($userRole->getRole()->getName());
}
But i am wondering if thats the correct way or if its also possible to get the Roles directly? like : Or is that only possible if i write my own method in the User Model class?
$user->findFirst()->getRoles();
Thanks for your advice. Patrick