Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update pivot field via editableIndex tries to update related model in stead of pivot model #53

Open
AforDesign opened this issue Jan 17, 2022 · 0 comments

Comments

@AforDesign
Copy link

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 set is_default = 0, Model-B.updated_at = [date] where id =[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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant