nova-toggle
nova-toggle copied to clipboard
update pivot field via editableIndex tries to update related model in stead of pivot model
Thanks for creating this great and very helpful package.
It works without problems in most cases, but I did encounter a bug in the following situation (models are set correctly):
- Model-A has a BelongsToMany Field, attaching it to Model-B
- The pivot tabel of Model-A_Model-B has an additional field, for example 'is_active'
- This pivot field is included in the BelongsToMany relation, with the '->editableIndex()' method
- On the index page of Model A, the toggle shows the correct value Thus it's value is correctly interpreted by the Toggle field (wonderful!)
- When you click on the toggle An error occurs:
SQLSTATE[42S22]: Column not found:
1054 Unknown column 'is_active' in 'field list' (
SQL: update
Model-B
setis_default
= 0,Model-B
.updated_at
= [date] whereid
=[id of model-B) - The update function, tries to updated the field in the table of the related model insted of the pivot table
So, in short: The field is shown correctly on the index view, but updating it targets the wrong table (/model)