/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id, CreateArticleRequest $request, Article $article) { $article_to_update = $article->find($id); $uploaded_image = $request->file('image_file'); $parameter = $request->all(); if (isset($uploaded_image)) { $ext = $uploaded_image->getClientOriginalExtension(); $newImageName = $article_to_update->id . "." . $ext; $uploaded_image->move(base_path() . '/public/img/uploads/article/', $newImageName); Image::make(base_path() . '/public/img/uploads/article/' . $newImageName, array('width' => 170, 'height' => 120))->save(base_path() . '/public/img/uploads/article/' . $newImageName); unset($parameter['image_file']); $parameter['image'] = $newImageName; $article_to_update->update($parameter); } else { $parameter['image'] = $article_to_update->image; $article_to_update->update($parameter); } Session::flash('message', 'The article was successfully edited!.'); Session::flash('flash_type', 'alert-success'); return redirect('articles'); }