/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $article = Article::find($id); return view('home.show', ['article' => $article]); }
/** * 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'); }