/** * Update the specified Product in storage. * PUT/PATCH /products/{id} * * @param int $id * @param Request $request * * @return Response */ public function update($id, Request $request) { $input = $request->all(); /** @var Product $product */ $product = $this->productRepository->apiFindOrFail($id); $result = $this->productRepository->updateRich($input, $id); $product = $product->fresh(); return $this->sendResponse($product->toArray(), "Product updated successfully"); }
/** * Update the specified Product in storage. * * @param int $id * @param UpdateProductRequest $request * * @return Response */ public function update($id, UpdateProductRequest $request) { $product = $this->productRepository->find($id); if (empty($product)) { Flash::error('Product not found'); return redirect(route('products.index')); } $this->productRepository->updateRich($request->all(), $id); Flash::success('Product updated successfully.'); return redirect(route('products.index')); }
/** * Update the specified Product in storage. * * @param int $id * @param UpdateProductRequest $request * * @return Response */ public function update($id, UpdateProductRequest $request) { // dd($request); $input = $request->all(); if (array_key_exists('thumbnail', $input)) { $file = $input['thumbnail']; $file_id = $this->addThumbnail($file); $input['thumbnail_id'] = $file_id; } $product = $this->productRepository->find($id); if (empty($product)) { Flash::error('Product not found'); return redirect(route('products.index')); } $product = $this->productRepository->updateRich($input, $id); Flash::success('Product updated successfully.'); return redirect(route('products.index')); }