I have a nasty problem using the latest assembly of OctoberCMS (318), where it tries to save invalid data in a pivot table instead of a model table.
I have a Businesses model and model watches:
Model for enterprises:
`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 - pivot table with business_id and openinghours_id
And the model to open:
public $table = 'ekstremedia_emcityportal_openinghours'; public $belongsToMany = [ 'businesses' => ['Ekstremedia\EmCityportal\Models\Business', 'table' => 'ekstremedia_emcityportal_businesses', 'order' => 'created_at desc' ] ];
In the field.yaml business controllers field.yaml I did this to add hours of work to the business:
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
The problem is that October tries to save hours of work in the pivot table, not in the model table. Anyone have an idea how I can fix this? Ive tried many different options ..
This is the error I get on the server:
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 , etc. is in ekstremedia_emcityportal_openinghours defined in the Openinghours model, and not in ekstremedia_emcityportal_ohb , which is a pivot table ...