On my User model, I was using both the CausesActivity and LogsActivity traits, and now with 1.1.0 there is a conflict because the activity() method was added to both traits. What is the best way to achieve this? For now I've simply added LogsActivity::activity insteadof CausesActivity to my class, but I feel like this isn't ideal nor semantically appropriate.
The use case is simple: A User causes activities, but a user can also edit other users, and I want those activities to be logged.
(I realise these particular traits aren't all that complicated, but I could see them growing in the future.)
You're right, it isn't ideal and I haven't foreseen this situation.
On first thought it would be better if I named those methods loggedActivity and causedActivity. For now I'd only use one of the two trait on your model and add your own loggedActivity and causedActivity methods.
I'll fix this in the next major release.
I think for now I'm not actually using the CausesActivity trait relationships at all, so I'll just remove it entirely. Thanks!
@freekmurze Does this have something that can be tracked to see when it would be implemented? I have hit a scenario where I want to monitor activity against a model as well as monitor any activity it causes. Thanks!
Just keep an eye on this repo, our my blog. This problem alone does not warrant an new major version in my mind, so it might take a while until a new major version will be released.
I ran into this issue as well with the same use case (a user who causes & logs activity). I'll use the recommended solution but it'd be nice if the package handled this out of the box.
By the way, I really appreciate all the many contributions by spatie. Great packages!
Most helpful comment
You're right, it isn't ideal and I haven't foreseen this situation.
On first thought it would be better if I named those methods
loggedActivityandcausedActivity. For now I'd only use one of the two trait on your model and add your ownloggedActivityandcausedActivitymethods.I'll fix this in the next major release.