laracasts / larabook

Larabook Series
142 stars 65 forks source link

Where would we define additional rules for the FollowUserCommandHandler #4

Open mathiasgrimm opened 9 years ago

mathiasgrimm commented 9 years ago

https://github.com/laracasts/larabook/blob/master/app/Larabook/Users/FollowUserCommandHandler.php

Say we have other parts of the application using this command to follow users. For example we could read a csv file to create this relationships and call the same command.

My question is where we should define the rule to not allow one user to follow another user more than once? I know we can define a unique key on the database. But where, in the application level?

Should it be defined/called from the handle method? Would it be something like "beforeHandle"

I know it's quite open and application dependent, but I would like to have a general idea. Another question is where to define a db transaction? Controller? meta command?

Thanks

mathiasgrimm commented 9 years ago

@JeffreyWay Would you help me to clarify?