Best way to separate my code

Posted 8 months ago by deansatch

Lets say I have a front end system and a backend system. On the frontend a visitor can place an order and will be automatically registered as a 'user', they will also be a 'customer' with an 'order'. On the backend an admin would be able to add a 'customer', optionally then add a user for that customer, and at any time add an 'order'

For the backend it is quite straight forward that I can create a user or a customer and link them together at any point with a pivot table. Adding an order of course is also straight forward. But for the front end forcing all 3 to happen I'd need to call each of those functions.

What would be the best way to organise these 3 'tasks'? Are they Events? Jobs? Or just simple public methods that I should call sequentially in a transaction in my controllers?

Basically I'm thinking it would be nice to be able to (from anywhere) createUser()...or createCustomer() or - createUser() with createCustomer() instead of createUser(), createCustomer(), linkUserAndCustomer()

Apologies for not using actual code, I'm looking more for the best practice as opposed to code examples.

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

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.