A while ago when I was working on a medium-size CRM-system I stumbled into a serious issue. First of all I had to log every single activities from each users in the system. Every time something new happened.
before traits and in the old times I used do like this. EACH time i wanted to create/update & delete. Imagine pasting this code +100 times in different files in a medium-size system🤦♂️
Luckily I knew that there had to be other ways to log activities. And I discovered Traits & Polymorphic in Laravel. Very powerful.
My trait is triggered each time a user create, update or delete anything within a specific model. I also choose to store data in json.
Now I'm able to use my Trait within other classes like this. No more adding functions after a submit just for tracking logs.