Skip to content

Pivot table without id column #549

@justrustyspoons

Description

@justrustyspoons
Q A
Bug? yes
New Feature? no
Framework Laravel
Framework version 6.x.y
Package version 9.x.y
PHP version 7.3.y

Actual Behaviour

When updating a pivot table without an id column it throws an error that the auditable_id cannot be null

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'auditable_id' cannot be null

Expected Behaviour

Insert without auditable_id for pivot tables

Steps to Reproduce

calling $model->relationship()->updateExistingPivot($relationship_id, $data) in a controller throws the error SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'auditable_id' cannot be null

Possible Solutions

Update migration to nullableMorphs('auditable') however this results in null values being recorded for old_values. Needs to record old_values through relationship instead of by pivot id

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions