info($service->brand)->firstOrFail(); $type = ArcadiaMailType::make(intval($request->type)); $orderType = ArcadiaOrderType::make(intval($request->state_order)); $xml = $this->makeXml($request, $type, $orderType, $customer, $customerInfo); // Format xml $doc = new DOMDocument('1.0', 'utf-8'); $doc->preserveWhiteSpace = true; $doc->formatOutput = true; $doc->loadXML($xml); $xml = $doc->saveXML(); Storage::disk('arcadia')->put(date("Ymd_His") . ".xml", $xml); return response()->json(); } catch (\Exception $e) { Log::critical("ARCADIA XML CREATION FAILED : " . $e->getMessage()); if (!config('app.debug')) { dispatch(function () use ($xml, $e) { Mail::to(config('mail.MAIL_ADMIN'))->send(new CourrierArcadiaError( "ARCADIA XML CREATION FAILED", "Une erreur est survenue lors de la création du fichier XML : " . $e->getMessage(), $xml )); })->afterResponse(); } else { throw $e; } throw new ApiErrorException(ApiError::arcardiaXmlMailFailed()); } } /** * render Arcadia xml for order * * @param SendArchadiaMailRequest $request * @param ArcadiaMailType $type * @param ArcadiaOrderType $orderType * @param Customer $customer * @param CustomerInfo $customerInfo * @return string */ private function makeXml( SendArchadiaMailRequest $request, ArcadiaMailType $type, ArcadiaOrderType $orderType, Customer $customer, CustomerInfo $customerInfo ): string { return view( 'mail.arcadiaOrders.default', [ 'request' => $request, 'type' => $type, 'orderType' => $orderType, 'customer' => $customer, 'customerInfo' => $customerInfo ] )->render(); } }