-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
updated_at in custom pivot table works incorrectly #34548
Comments
I'm suspecting #30697 to be the culprit but trying to find out why this is breaking for you. Can you please paste your models/pivot and how you're using this exactly? |
I've created a demo project which shows how to reproduce the issue. You can see an exception executing
Post model has relation to Comment model using PostHasComments pivot model. |
After a long and deep dive into this I've determined that this has never worked, not even in 5.8. I tested with your code in a fresh 5.8 install and I get the same error. The Pivot always expects a created_at and updated_at column to be present and indeed derives their names from the parent model if not set explicitly. Their names are set on the pivot model through the As this is sort of expected behavior (for now) I'm closing this. We can look into improving this but that's an enhancement rather. I'll send in a PR to the docs to document this. Thanks. |
PR for docs was merged: laravel/docs#6427 |
Description:
Defining UPDATED_AT as
null
in custom intermediate pivot table seems to be broken.$this->getUpdatedAtColumn()
gets column name from parent model instead of custom pivot and as result it fails inserting to undefined column.In version 5.8 column name was retrieved by
static::UPDATED_AT
and behaved right.The text was updated successfully, but these errors were encountered: