I'm currently building a Website with OctoberCMS and i have a Database Products with a list of Products. Those Products should be linked to other Products of the Same table. I have tried to achieve that trough a Pivot Table. Can it be done?
My fields.yaml:
fields:
name:
label: Produkt
oc.commentPosition: ''
span: auto
type: text
active:
label: Aktiv
span: auto
default: 1
type: switch
content:
label: Beschreibung
size: ''
oc.commentPosition: ''
span: auto
type: richeditor
sorting:
label: Sortierung
oc.commentPosition: ''
span: auto
type: number
products:
label: Relation
oc.commentPosition: ''
nameFrom: name
descriptionFrom: description
span: auto
type: relation
My columns.yaml:
fields:
name:
label: Produkt
oc.commentPosition: ''
span: auto
type: text
active:
label: Aktiv
span: auto
default: 1
type: switch
content:
label: Beschreibung
size: ''
oc.commentPosition: ''
span: auto
type: richeditor
sorting:
label: Sortierung
oc.commentPosition: ''
span: auto
type: number
products:
label: Relation
oc.commentPosition: ''
nameFrom: name
descriptionFrom: description
span: auto
type: relation
Relation:
public $belongsToMany = [
'products' => [
'XXX\Produkte\Models\Produkt',
'table' => 'XXX_produkte_relations'
]
];
The Result should be a Pivot Table with two ids of the two selected Products.
I get one entry in my Pivot Table but not the second id. Thanks for any Help!