/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(ArticleRequest $request, $id) { if ($request->file('image')) { # code... $file = $request->file('image'); $name = 'blogexodia_' . time() . '.' . $file->getClientOriginalExtension(); $path = public_path() . '/images/articles/'; $file->move($path, $name); } $article = Article::find($id); $article->fill($request->all()); $article->save(); $article->tags()->sync($request->tags); $image = new Image(); $image->name = $name; $image->article()->associate($article); $image->save(); Session::flash('message', 'Articulo Actualizado Correctamente'); return Redirect::to('article'); }
public function edit(Post $post) { $images = Image::latest()->take(10)->get(); $locations = Location::latest()->take(10)->get(); return View('admin.posts.edit', compact('post', 'images', 'locations')); }
public function update(Image $image, EditImageRequest $request) { $image->update($request->all()); return redirect('admin/images'); }