I need to connect components with links by relationship Many to Many .
Therefore I have a components table and a pivot table named components_components.
A component is linked to another one. Many kind of links can exist between two components. Component From ====> Component To
I understand that I need to have a specific joinModel because conventions are not ok, but i don’t understand well how to set parameter for relationships in both tables.
Can you help me to find out the good way to use cakephp in this case ?
Can’t guarantee success, but I believe this would work:
// A component sees its parents here
$this->belongsToMany('ParentComponent', [
'className' => 'Components',
'foreignKey' => 'component_from_id',
'targetForeignKey' => 'component_to_id'
]);
// A component sees its children here
$this->belongsToMany('ChildComponent', [
'className' => 'Components',
'foreignKey' => 'component_to_id',
'targetForeignKey' => 'component_from_id'
]);
Scroll down a little from here and you’ll find a complete list of configuration keys and their use.