ImArtur
192
2
Laravel

Using trait on Observer

Posted 1 year ago by ImArtur

I'm wondering. Right now i'm creating a Activity Model to store all user activity. I'm following Jeff tutorial TDD series. Instead of calling observer directly from model like Jeff did it, I have a dedicated Observer method. I want to monitor users different activities like Edit the post, add a comment etc. All of those activities will use the same polymorphic relationship to store. My question is: If I create ThreadObserver & PostObserver both of them are using the same functionality. Should i create some ActivityTrait to prevent copying methods from one observer to another? Or how should I approach it?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.