I have doctor
and specialization
table, and have doctor_specialization_pivot
table. In my pivot table I have the following columns:
| doctor_id | additional_data | specialization_id |
additional_data
is from the doctor
model along with the doctor_id
.
In my doctor
model file, I have this relationship:
public $belongsToMany = [
'specialization' => [
'path\to\specialization\model',
'table' => 'doctor_specialization_pivot',
'parentKey' => 'doctor_id',
'otherKey' => 'specialization_id',
]
];
Now during submit of form, I'm getting this error:
SQLSTATE[HY000]: General error: 1364 Field 'additional_data' doesn't have a default value (SQL: insert into doctor_specialization_pivot (doctor_id, specializations_id) values (1, 3))"
I tried adding to my relationship 'pivot' => ['additional_data']
. But still getting the same error.
I checked the submitted data and additional_data
is not empty. I checked from OctoberCMS forums but not getting straight forward answers such as this and this.