/** * @param NewProductOptionRequest $request * * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response */ public function postNew(NewProductOptionRequest $request) { $product = $this->catalogueRepository->loadProductById($request->productId()); $option = $this->catalogueRepository->addOptionForProduct($product, $request->label()); $this->webUi->successMessage("Added new option `{$option->label}` for product `{$product->sku}`"); return $this->webUi->redirect('products.show', [$product->sku]); }
/** * @param int $productId * @param int $imageId * * @return RedirectResponse */ public function detachImage(int $productId, int $imageId) { $product = $this->catalogueRepository->loadProductById($productId); $image = $this->catalogueRepository->loadImageById($imageId); $this->catalogueRepository->detachImageFromOwner($image, $product); $this->webUi->successMessage("Removed one image from product `{$product->sku}`."); return $this->redirectToShowProduct($product->sku); }