It’s down to preferences. As long as you are using the correct standards, you should be fine!
So in Laravel, I use Models
strictly for database operations. I also create a folder called Services
and another folder called Hydrators
My services in the service folder handles the business logic e.g grabbing data from the models and any logical operations. My hydrators take the data and sort it in the way I want the data to be presented to the view.
Both my services and hydrators take on the Single Responsibility Principle as this allows me to reuse the same code elsewhere to avoid code duplication!
My controllers are just an entry point to the back end and only do two things; call the services and stitch the ones needed together and return a result (a result could be anything from JSON to a view with data).
This is just my personal way of doing things. Others may have a different way.
1
solved Where I must contain business logic of my application? [closed]