authorize('associateInco', $product); try { $preview = $this->executor->execute( $query, $request->toGetArcadiaIncoPreviewQueryInput(), ); } catch (\RuntimeException $e) { return response()->json([ 'message' => __('Arcadia API error: :error', ['error' => $e->getMessage()]), ], 502); } if ($preview === null) { return response()->json([ 'message' => __('No INCO sheet found on Arcadia for this article number.'), ], 404); } return response()->json($preview); } public function associate(AssociateProductIncoRequest $request, Product $product, AssociateProductInco $action): RedirectResponse { $this->authorize('associateInco', $product); try { $inco = $this->executor->execute( $action, $request->toAssociateProductIncoInput($product->getId()), ); } catch (\RuntimeException $e) { return back()->with('danger', __('Arcadia API error: :error', ['error' => $e->getMessage()])); } return to_route('bo.products.incos.edit', compact('product', 'inco')) ->with('success', __('The INCO sheet has been successfully associated with the product.')); } public function sync(SyncProductIncoRequest $request, Product $product, SyncProductInco $action): RedirectResponse { $this->authorize('syncInco', $product); try { $inco = $this->executor->execute( $action, $request->toSyncProductIncoInput($product->getId()), ); } catch (\RuntimeException $e) { return back()->with('danger', __('Arcadia API error: :error', ['error' => $e->getMessage()])); } return to_route('bo.products.incos.edit', compact('product', 'inco')) ->with('success', __('The INCO sheet has been successfully synchronized from Arcadia.')); } public function edit(Product $product, GetProductIncoForEditQuery $query): View { $this->authorize('associateInco', $product); $output = $this->executor->execute( $query, new GetProductIncoForEditQueryInput($product->getId()), ); return view('bo.product-incos.edit', [ 'product' => $output->product, 'inco' => $output->inco, ]); } }