-
There is no single list with "always good" patterns and "always bad" patterns. It's up to you to choose right things. As long as the code fulfills it's task, it satisfies you, you understand it and you're able to support it, develop and extend through time - the code is good. If you feel uncertain - do it first way, the worst would happen is you feel it's bad and do it other way. Next time you'll know what is right in such situation.
Some people say having a dedicated service over Eloquent is unneccessary overkill: Eloquent is already a sufficient "service" over database and SQL itself, and scopes give enough flexibility. But again, it's up to you. -
I don't like it, personally. Exceptions are for errors (or, at least, for handling unpredicted behavior of app). Instead, I would consider to return a data object with all fields you need.
Sep 8, 2025
3
Level 1
Organizing usage of multiple services in a single http controller
Hello everybody, love the forum and am looking for some feedback on my code.
I am building out a feature for using coupons during Stripe checkout.
I have 2 services:
- 1 for handling the database model/table "coupons" -> CouponService
- 1 for making API calls to Stripe\Coupons -> StripeCouponService
As I was writing my controller I noticed that for each CRUD I had to:
- call the CouponService
- call the StripeCouponService
This wasn't clean so I resorted to creating a 3rd "manager service" where I do calls to both of the aforementioned services.
Now the one I call inside of the controller is the manager one.
I have 2 questions:
- Is this a good pattern to follow?
- In cases of a service function needing to handle multiple return cases, does throwing exceptions and then catching them at the controller level seem good?
Please or to participate in this conversation.