-
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
[5.8] Custom pivot class causes updated_at not to be updated #29321
Comments
This was caused by #27571. /cc @ralphschindler |
Any news about that issue ? |
I am trying to write a test for this behavior. Standby. |
PR was merged. |
@driesvints Please reopen, the linked PR is an old one. This issue hasn't been fixed yet. |
Earlier, i was thinking that this pr (28416) may be related to my issue, and commented, |
@staudenmeir I meant this PR: #29362 |
@driesvints That's also a different issue ;-) |
Okay lol |
@driesvints Sorry for confusing mention |
Very ditry hack: $this->newPivot([
$this->foreignPivotKey => $this->parent->{$this->parentKey},
$this->relatedPivotKey => $this->parseId($id),
+ (new $this->using)->getCreatedAtColumn() => null,
], true)->fill($attributes)->save(); It forces |
Okay I got the better implementation, I'll submit PR |
@lk77 Would you test it based on this PR branch? |
@mpyw i pulled your fork and updated my demo : https://github.com/lk77/pivot-using-update-bug
the dates are equal. thanks |
Description:
Hello,
we have an issue when using a custom pivot class, with an additional pivot attribute. The
updated_at
field is not updated, while the value of the additional field is updated, when usingsync()
method on the belongsToMany relation. We tried to add$timestamps = true
to the custom pivot class but it's not working.Let's say for example, that we have a
users
table, aroles
tables, and ausers_has_roles
pivot table with a additionalcomment
field.If we
sync
the relation without a call tousing()
, so without custom pivot class, it's working fine, the comment is updated, and theupdated_at
field too.But if we add
using()
to our relation method, so with custom pivot class, it's not working fully,the
comment
is updated, but theupdated_at
field is not.Steps To Reproduce:
1 / clone https://github.com/lk77/pivot-using-update-bug
2 / configure .env and execute php artisan migrate --seed
3 / php artisan serve
4 / go to localhost:8000
5 / See that the two dates differs (one is calling
using()
the other is not)thanks.
The text was updated successfully, but these errors were encountered: