gpt4 book ai didi

laravel - 我的 Octobercms 数据透视表获得了模型表在我尝试添加时应该获得的数据

转载 作者:行者123 更新时间:2023-12-04 21:36:28 25 4
gpt4 key购买 nike

我有一个烦人的问题,使用最新的 OctoberCMS build (318),它试图将错误的数据保存到数据透视表而不是模型表。

我有一个模范企业和一个模范营业时间:

企业模式:

`public $table = 'ekstremedia_emcityportal_businesses';`
`public $belongsToMany = [
'openinghours' => [
'Ekstremedia\EmCityportal\Models\Openinghours',
'table' => 'ekstremedia_emcityportal_ohb',
'order' => 'week_day',
'week_day' => 'week_day',
'name' => 'week_day',
]
];`
ekstremedia_emcityportal_ohb是带有 business_id 的数据透视表和 openinghours_id
和开放时间模型:
public $table = 'ekstremedia_emcityportal_openinghours';
public $belongsToMany = [
'businesses' => ['Ekstremedia\EmCityportal\Models\Business',
'table' => 'ekstremedia_emcityportal_businesses',
'order' => 'created_at desc'
]
];

在业务 Controller field.yaml我已经这样做了,为企业增加营业时间:
    openinghours:
type: repeater
label: 'Åpningstider'
tab: 'Åpningstider'
form:
fields:
week_day:
label: Dag
oc.commentPosition: ''
options:
1: Måndag
2: Tysdag
3: Onsdag
4: Torsdag
5: Fredag
6: Laurdag
7: Sundag
span: left
type: dropdown
open_hour:
label: Date added
type: datepicker
mode: time
close_hour:
mode: time
label: Date added
type: datepicker

问题是,october 试图将开放时间保存到数据透视表而不是模型表。任何人都知道我该如何解决这个问题?我尝试了很多不同的选择。 .

这是我在后端得到的错误:
 SQLSTATE[42S22]: Column not found: 1054 Unknown column 'close_hour' in 'field list' (SQL: insert into 'ekstremedia_emcityportal_ohb' ('business_id', 'close_hour', 'open_hour', 'openinghours_id', 'week_day')...
close_hour , open_hour , openinghours_id , week_day等,在 ekstremedia_emcityportal_openinghours ,定义于 Openinghours模型,不在 ekstremedia_emcityportal_ohb这是数据透视表......

最佳答案

嗨,我认为您的案例是一个复杂的关系场景,对于 10 月的 cms 作为为您处理此问题的工具,它是 relation behavior事实上,表单行为对于简单的关系就足够了,或者当你在创建它们之后链接时思考。

在这里,您试图同时创建一个保存。
有一个 pretty good ressource about it我认为了解关系行为就足够了。

但是营业时间是否属于多个业务?

关于laravel - 我的 Octobercms 数据透视表获得了模型表在我尝试添加时应该获得的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36393632/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com