productSolver = $this->loadService(ProductSolver::class); } public function instanciate(): ProductOrder { $productOrder = new ProductOrder(); return $productOrder; } public function updatePrice( ProductOrder $productOrder, User $user = null, UserProducer $userProducer = null, PointSale $pointSale = null, int $quantity = 1) { $productOrder->price = $this->productSolver->getPrice( $productOrder->product, [ 'user' => $user, 'user_producer' => $userProducer, 'point_sale' => $pointSale, 'quantity' => $quantity ]); $productOrder->save(); return $productOrder; } public function updateInvoicePrice(ProductOrder $productOrder, array $params = []): void { $productOrder->invoice_price = $this->productSolver->getPrice($productOrder->product, [ 'user' => isset($params['user']) ?? null, 'user_producer' => isset($params['user_producer']) ?? null, 'point_sale' => isset($params['point_sale']) ?? null, 'quantity' => $productOrder->quantity ]); $productOrder->save(); } public function deleteByOrder(Order $order): void { ProductOrder::deleteAll(['id_order' => $order->id]); } }