/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id, Slider $slider, CreateSliderRequest $request) { $slider_to_update = $slider->find($id); $uploaded_image = $request->file('image_upload'); if (isset($uploaded_image)) { $ext = $uploaded_image->getClientOriginalExtension(); $newImageName = $slider_to_update->id . "." . $ext; Image::make(base_path() . '/public/img/uploads/slider/' . $newImageName, array('width' => 774, 'height' => 329))->save(base_path() . '/public/img/uploads/slider/' . $newImageName); $parameter = $request->all(); $parameter['image'] = $newImageName; /* remove this field from the parameters list */ unset($parameter['image_upload']); $slider_to_update->update($parameter); } else { $slider_to_update->update($request->all()); } Session::flash('message', 'The content was successfully updated!.'); Session::flash('flash_type', 'alert-success'); return redirect('sliders'); }
/** * Update the specified resource in storage. * * @param CreateSliderRequest $request * @param Slider $slider * @return Response */ public function update(Slider $slider, CreateSliderRequest $request) { $slider->update($request->all()); return redirect()->action('sliderController@index'); }