我目前正在使用OctoberCMS建立一个网站,我有一个包含产品列表的数据库产品。这些产品应链接到同一表的其他产品。我试图通过数据透视表实现这一点。可以吗?
我的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
我的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
关系:
public $belongsToMany = [
'products' => [
'XXX\Produkte\Models\Produkt',
'table' => 'XXX_produkte_relations'
]
];
结果应该是一个数据透视表,其中包含两个选定产品的两个ID。
我在数据透视表中输入一个条目,但不是第二个ID。感谢您的帮助!