FoxSecrets
Active member
I am trying to build a relation from addon1 to addon2 (one to one), but it's not working. Something missing on my configuration?
Some questions:
ADDON 1
ADDON 2 - My\Addon2:Class
Some questions:
- On the example below, what does 'Category' relation refers to, can be any name?
- Is my 'entity' correct to point to another addon?
- Does the recording order matter?
ADDON 1
Code:
// ...
$structure->columns = [
'product_id' => ['type' => self::UINT, 'autoIncrement' => true],
'product' => ['type' => self::STR, 'maxLength' => 50, 'default' => '']
'category_id' => ['type' => self::UINT, 'default' => 0],
];
$structure->relations = [
'Category' => [
'entity' => 'My\Addon2:Class',
'type' => self::TO_ONE,
'conditions' => 'category_id',
'primary' => true
],
// ...
ADDON 2 - My\Addon2:Class
Code:
// ...
$structure->columns = [
'category_id' => ['type' => self::UINT, 'autoIncrement' => true],
'category' => ['type' => self::STR, 'maxLength' => 50, 'default' => '']
];
// ...
Last edited: