Skip to content
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

Add possibility to add revision when we change something with many-to-many relationship. #63

Open
tommy7600 opened this issue Jun 20, 2014 · 13 comments
Milestone

Comments

@tommy7600
Copy link

Add possibility to add revision when we change something with many-to-many relationship.

@duellsy
Copy link
Member

duellsy commented Jun 20, 2014

Open to pull requests on this one, I'm assuming you're talking about additional data updated on the pivot table?

@tommy7600
Copy link
Author

Yes, I am talking about saving information from pivot table. I found solution to my problem, but it is very specific situation, so maybe we can even call my solution as a hack ;)
I opened this issue, because I don't have any idea how to expand your module and add generic solution for this kind of situations.

@duellsy
Copy link
Member

duellsy commented Jun 23, 2014

Keen to see what you did

@duellsy duellsy added this to the v2.0.0 milestone Jun 23, 2014
@deletosh
Copy link
Contributor

deletosh commented Aug 7, 2014

@tommy7600 I'm also interested in seeing how you did this.

@kz
Copy link

kz commented Jun 25, 2015

@tommy7600 Ditto. I'm using attach() and detach(). Perhaps we could extend attach() and detach() and listen for when they are called, and then fire our own event which we listen to.

@oozrafa
Copy link

oozrafa commented Sep 27, 2016

Any progress on this very important missing feature?

@gn0rt0n
Copy link

gn0rt0n commented Oct 5, 2016

I really need this feature as well. I am open to sponsoring some development time on it. Let me know if you have an idea on how to implement this and roughly what it would take to get the work done.

@aske-cph
Copy link

I am also interested in this. Links to custom solutions also appreciated if development has stalled...

@molerat619
Copy link

any news 4 years later?

@jtomek
Copy link

jtomek commented May 13, 2022

any news 3 years later?

@MuriloChianfa
Copy link

MuriloChianfa commented Apr 1, 2023

The biggest problem is that we don't natively have Many to Many events.

If we use the laravel-pivot package, we can monitor the pivot updates and store new revisions for both many to many classes, we only have to wait the acceptance of changes in fico7489/laravel-pivot#91

In my use case, i have a many to many relation in ports to port group:
image
image
image

And the attach and detach events can now generate revisions as u can see in the "History changes" section on my software:
image
image

This will generate two revisions, one revision for each model, as we can see above.

Its simple to implement with laravel-pivot package, but im having trying yet

However if the intermediate table has some more fields, we would not be able to store it in the current "revisions" table, we would have to add some more fields to accommodate this, because in the database i have used the old_value and new_value to store the model target hahahaha.
image

Do you think it's a good idea to try adding some more fields to the table or is it worth creating another table of revisions for the case of Many to Many?

@duellsy
Copy link
Member

duellsy commented Apr 4, 2023

@MuriloChianfa nice, will this support storing any changes that are made to other fields that might be on the pivot table, or limited only to the creation / destruction of a pivot?

@MuriloChianfa
Copy link

@duellsy only create and delete because, to add the pivot fields, we would have to add more fields to the revisions table, I imagine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants