canCreateOrder = $canCreateOrder; $this->createsOrder = $createsOrder; $this->confirmOrderProcessor = $confirmOrderProcessor; $this->createOrderStepsProcessor = $createOrderStepsProcessor; $this->unityCreateContract = $unityCreateContract; } public function execute(Request $request){ $reference_no = rand(1000000, 9999999); //TODO: Call Unity to create contract and get contract reference no (and all the obligations) $contract = $this->unityCreateContract->execute(); $contract_reference_no = $contract->hash_id; $contract_obligation_list = $contract->contract_obligation_list; $order_object = new OrderObject($request->get('company_module_id'), $contract_reference_no, '', OrderType::SHARED_CONTAINER, OrderStatus::PROCESSING, OrderSteps::PROCESSING); $this->canCreateOrder->passes($order_object); $order = $this->createsOrder->execute($order_object); //Add processing to order step //Note: For processing apointee_id is CIEF Freight Forward , id is 1, reserved in company table $this->createOrderStepsProcessor->execute($order, OrderSteps::PROCESSING, 1); //Pre-approved order, no need Admin to process it $this->confirmOrderProcessor->execute($order->id); //TODO: Add order roles - Allow multiple entity to process this order return $order; } }