4 years ago

API + Backoffice + Front end: Code organization

Posted 4 years ago by SergioGregorutti

Hi all,

Im working on my first Laravel project and I have an API, a Backoffice and of course the front end.

For each one I have different controllers and my concern is about what is the best way to improve the code and not repeat it.

For example, on my application for "Create a new commerce" I have 3 ways to do it:

  • via Backoffice (with backoffice Admin/CommerceController)
  • via Front end (the current user with CommerceController)
  • via API (API/CommerceController, maybe in the future from a native mobile app)

So, I have 3 times the same code. What is the best approach to have the code just once? I think that maybe I need to do all the actions with the API, and call it from Front-end/Backoffice controllers, but how?

Any suggestions?

Thanks in advance!

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