/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(UpdateProductRequest $request, Product $product) { $data = $request->input(); $product->fill($data); $product->save(); $this->savePhoto($product, $request); $product->categories()->detach($product->categories()->lists('id')->toArray()); $product->categories()->attach($data['categories']); return Redirect()->route('home'); }
/** * Update the specified resource in storage. * * @param StoreProductRequest|UpdateProductRequest|\Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(UpdateProductRequest $request, $id) { $input = $request->input(); $product = Product::findOrFail($id); if ($request->hasfile('image')) { $input = $this->setImage($request->file('input'), $input); $this->deleteImage($product->image, $product->thumbnail); } $product->update($input); return redirect()->action('CategoryController@show', [$input['category_id']]); }