My 3 Models
class Users extends Model {
public function initialize() {
$this->hasManyToMany('id', __NAMESPACE__ . '\UsersRoles', 'userid', 'roleid', __NAMESPACE__ . '\Roles', 'id', array("alias" => "Roles"));
}
}
class Roles extends Model {
public function initialize() {
$this->hasManyToMany('id', __NAMESPACE__ . '\UsersRoles', 'roleid', 'userid', __NAMESPACE__ . '\Users', 'id', array("alias" => "Users"));
}
}
class UsersRoles extends Model {
public function initialize() {
$this->belongsTo("userid", __NAMESPACE__ . "\Users", "id", ["alias" => "user"]);
$this->belongsTo("roleid", __NAMESPACE__ . "\Roles", "id", ["alias" => "role"]);
}
}
the use of getRelationsBetween in controller
$modelUsers = __NAMESPACE__."\Users";
$modelRoles = __NAMESPACE__."\Roles";
$this->modelsManager->initialize(new $modelUsers());
$rel = $this->modelsManager->getRelationsBetween($modelUsers, $modelsRoles);