Skip to content

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

@AforDesign

Description

@AforDesign

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions