-
Notifications
You must be signed in to change notification settings - Fork 394
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
Not logging Affected Relations? #58
Comments
The auditing currently uses events, but in case of pivots, there are no events being triggered. There are many issues reported regarding this. See for example here: laravel/framework#8452 . |
Can you not just override those methods like sync, attach and detach? Or even better would be a chain on the relationship in some way, will explain more if I come up with a way of doing this. Trying out this package and I think we will need it to work for this and we can work around it easy enough, if a workaround is good enough we will make a PR. |
Sorry for the delay. Hello @robclancy , let's think of something. I'll keep this open to give continuity to this improvement. |
yes, 'sync attach detach' donot log, |
@fly-studio, as soon as version 4.0 is out the door, we'll try to work on many-to-many audit support for 4.1. |
When will release 4 version? 😃 |
@quetzyg Ok, thanks 😄 |
I strongly vote for this feature. I'm currently working on a custom auditor that would record (to a seperate table) the foreign key relationships relations to a separate table, then I extend $Model->getAuditArr() to pull it all together the way we want. Lots of DB hits and in general, not a perfect solution. Will switch off this when this feature is implemented. |
How progress here? 😀 |
+1 still waiting for the best solution |
considering using this package but I would need pivot auditing |
tenho o mesmo problema |
Experimental package for events in many to many relations: https://github.com/neylsongularte/eloquent-extra-events My temporary solution:
|
Any update concerning this problem? |
Hi everyone, I've been thinking in a few ways to achieve this, and I'm inclided to leave it up to the developer to implement part of the functionality. The package can already handle other events besides So, the idea is to add three new The developer would be responsible for firing/dispatching said events and pass the data they wish to audit/log. From that point on, the appropriate I think this brings a good balance between new feature and code complexity. Thoughts? |
@quetzyg Sounds good to me! Because there won't be an official support concerning the events, I think that's a very good way, especially because the developers are now "unrestricted". But please provide an example for the implementation in the docs 😛 |
@manniL, yeah, the idea is to keep it flexible, because I have no idea how developers want to store changes, specially when we're talking about And don't worry, the docs will be updated once this gets implemented. |
@quetzyg That's a good plan! Well, in my case I'd simply store the changes (e.g. User A Was linked to posts 1,2,3 and is now linked to Post 4,6,7, I'd just change the stored numbers). If the relation models itself were changed, it'd be fine if there would be an extra audit model for that. |
For a simple case like the one you described it's fine to use just one audit record, but when you have extra data in the pivot or when you detach hundreds of relations in one go, things would get out of hand very quickly and stuffing all that data in just one record would make it hard to track changes. But again, I'll leave that decision to the developer. |
@quetzyg Yes, this can become very hairy in situations like the one you described. But as the developers are flexible, everyone will adapt it to their needs :) |
I think I have a solution for issue. Are you accepting pull requests??? It has, I admin, some of the data issues stated above. I can have it done in acceptable form in a couple of Saturdays |
@jschlies, sure. Feel free to send a PR and we'll review it. |
I'm very curious! Good luck @jschlies and hit me up when u need help :) |
👍 |
Is the pivot observer already implemented in 5.8? |
Yes, @milhouse1337 shared here, take a look. |
Can you please explain more how to use with audit? |
Hi. |
Helo I also need this function for a projekt, is there news? |
I found a beter pakage https://altek.gitlab.io/accountant it works out of box for pivot relations super easy and no hacks |
@waska14 I have not implemented it yet |
@PizzaTibe Thanks for contributing, I will test this package. |
Laravel 5.8 now fires eloquent events if a custom Pivot model exists. Therefore, it should be possible to get pivot audits by
Maybe this should be added somewhere in the docs because this seems like it is a common question. |
I can confirm it works in Laravel 5.8. (https://laravel.com/docs/5.8/eloquent-relationships#defining-custom-intermediate-table-models) |
I'm surprised there has been no follow-up here since August, as I'm unable to get this working. It seems like, even if you have |
I gave up. To work I'm using this package: https://github.com/fico7489/laravel-pivot |
It looks like it was working in version 9.3.1 but then regressed in the latest release. Put an issue up about it, hopefully we can get it working again. |
Can you provide a gist ? |
@quetzyg do you have any plans on bringing the pivot auditing capability from your package Accountant into this one? |
I do not, but you can always use Accountant, instead. |
@quetzyg saving everything for one field change in a table with 30+ columns is overkill for my use-case, especially when 1 or 2 fields change frequently, so I prefer Auditing's flexibility. |
@quetzyg How to fire a relation? |
up |
could do optional functionality with Laravel Pivot (https://github.com/fico7489/laravel-pivot) |
new Pivot Model Events from laravel not the best style |
Any update on this idea @quetzyg |
@tmishutin like I said a few times before, I'm no longer a maintainer of this project. Read the entire thread for suggested alternatives if you require such feature. |
With version 13 we have addressed the oldest issue and now provide a way to solve this. https://www.laravel-auditing.com/docs/13.0/audit-custom |
Is it correct that any updated relations are not being logged in the database?
I'm using eloquent's sync() function a lot, for updating many-to-many relations...
Any ideas how to do that?
The text was updated successfully, but these errors were encountered: