The Problem
You have a multi-step operation. Maybe it’s processing an order: validate stock → apply discount → charge payment → send confirmation → notify warehouse. You could nest these calls:
// ❌ Nesting quickly becomes hard to follow public function handle ( CreateOrderRequest $request ) : JsonResponse { $order = $this -> stockService -> validate ( $request -> validated ( ) ) ; $order = $this -> discountService -> apply ( $order , $request -> coupon ) ; $order = $this -> paymentService -> charge ( $order ) ; $this -> notificationService -> sendConfirmation ( $order ) ; $this -> warehouseService -> notify ( $order ) ;
return OrderResource :: make ( $order ) -> response ( ) ; }
Enter fullscreen mode
Exit fullscreen mode
Or you could make a massive “God” service that does all of it. Neither is clean.…