0
I have the following table structure:
- Users
- Tools
- Groups
All of them have membership from Many to Many
And I already own the pivot Tables:
- groups_tools
- groups_users
- tools_users
I am trying to do the following query:
TableRegistry::get('Users')
->find()
->where(['id' => 1])
->contain(['Groups.Tools'])
->first();
I’m getting the following error
Groups is not Associated with Tools
However, I believe I’m following all the conventions.
class GroupsTable extends Table
{
public function initialize(array $config)
{
$this->addBehavior('Timestamp');
$this->belongsToMany('Tools');
$this->belongsToMany('Users');
}
}
class ToolsTable extends Table
{
public function initialize(array $config)
{
$this->addBehavior('Timestamp');
$this->belongsToMany('Users');
$this->belongsToMany('Groups');
}
}
class UsersTable extends Table
{
public function initialize(array $config)
{
$this->addBehavior('Timestamp');
$this->belongsToMany('Tools');
$this->belongsToMany('Groups');
}
}