public function update(EditProductRequest $request, $id) { $product = Product::findOrFail($id); $product->fill($request->only($product->getFillable())); $product->save(); return redirect()->route('product.index')->with('success_message', 'The product has been successfully saved.'); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(EditProductRequest $request, $id) { $product = Product::findOrFail($id); $product->fill($request->all()); $product->save(); return \Redirect::route('products.index'); }
/** * Update the specified product * * @param ProductRequest $request * @param Product $product * @return Response */ public function update(EditProductRequest $request, Product $product) { $input = $request->except('image'); $image = $request->file('image'); if (!isset($input['active'])) { $input['active'] = false; } if (!isset($input['new'])) { $input['new'] = false; } if ($image != null) { // Picture name will be same as SKU $name = $input['sku']; // Extenstion of original picture $extension = '.' . $image->getClientOriginalExtension(); // Set paths for full image and thumbnail $imagePath = 'img/' . $name . $extension; $thumbnailPath = 'img/thumbs/' . $name . $extension; // Save original picture \Image::make($image->getRealPath())->save(public_path($imagePath)); // Save resized thumbnail \Image::make($image->getRealPath())->resize(300, null, function ($constraint) { $constraint->aspectRatio(); })->save(public_path($thumbnailPath)); // Create Product model and save pictures $product->fill($input); $product->image = $imagePath; $product->image_thumb = $thumbnailPath; $product->save(); return redirect(route('AdminProductShow', $product->slug)); } $product->fill($input); $product->save(); return redirect(route('AdminProductShow', $product->slug)); }