protected InventoryService $inventoryService, protected PaymentService $paymentService, protected ShipmentService $shipmentService, ) {} public function handle(CartItemCollection $items, PaymentGateway $paymentGateway, int $userId): OrderDto { return $this -> database -> transaction(function () use ($items, $paymentGateway, $userId) { $order = Order::start($userId); $order -> addLinesFromCartItems($items); $order -> save(); $orderDto = OrderDto::fromModel($order); foreach ($items as $item) { $this -> inventoryService -> decreaseStock($item - > productId, $item -> quantity); } $payment = $this -> paymentService -> payOrder($orderDto, $paymentGateway); $order -> complete(); $this -> shipmentService -> startShipmentForOrder($orderDto); return $orderDto; }); } }