Pivot table without id column #777
-
Actual BehaviourWhen 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 BehaviourInsert without auditable_id for pivot tables Steps to Reproducecalling $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 SolutionsUpdate 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 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Instead, you can add auto-incrementing primary key and |
Beta Was this translation helpful? Give feedback.
-
And how about dettaching things ? :) |
Beta Was this translation helpful? Give feedback.
-
Can I use laravel auditing with parameter $incrementing = false? because the id in the table uses a string type. Thanks |
Beta Was this translation helpful? Give feedback.
Instead, you can add auto-incrementing primary key and
public $incrementing = true;
on pivot