I'm working on a pretty simple site for photo galleries, users have the ability to vote on their favorite photo in gallery. I have some events setup each time a user votes, a VoteCase event is called, which receives the vote object.
The VOTE object consist of...
- photoID
- voterID
The event receives the vote object and sends the photo owner and email saying their photo was chosen. There's a separate AppMailer.php class for sending the email.
My question is, obviously I need to do a lookup to see who the photo belongs to (I already have an eloquent relationship for that ($photo->user;
)
But is that the job of the event? To do a database call and retrieve the user object to pass to the AppMailer? Or should the AppMailer class receive the entire event, and do the user lookup itself?
There's a few other events associated with voting as well. incrementing vote count, giving the voting user credit and possibly assigning a "badge" etc. Each of these might have additional DB lookups. So knowing the best place to put this is helpful.
I've been told an event is very similar to a DTO, but my experience with them is non-existent.