How can I do multiple inserts in an API store() and not abuse Single Responsibility

Posted 4 years ago by jgravois

I have an angular client posting to an API controller to create a new farmer. The client doesn't know (nor should it) that a new farmer has to be a user first.

I need the store method of the FarmersController to get the email address out of Input and (1) check if the email exists in users and farmers table, (2) insert a record into the users table, (3) get back the insert id, (4) add the insert id into the Input object and then (5) insert the record into the farmers table.

How can I do 5 things in one controller and not abuse Single Responsibility?


How can I expect the client to know that 5 things have to happen?

OMG! I am sooo confused!

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