Exemplo n.º 1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(PostRequest $request, $id)
 {
     $post = Post::findOrNew($id);
     $post->update($request->all());
     if ($request->hasFile('link_thumbnail')) {
         $file = $request->file('link_thumbnail');
         $ext = $file->getClientOriginalExtension();
         $fileName = str_random(12) . '.' . $ext;
         $file->move('assets/img/confs', $fileName);
         $post->link_thumbnail = $fileName;
         $post->save();
     }
     return redirect('/dashboard');
 }
Exemplo n.º 2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $post = Post::findOrNew($id);
     return view('front.showPost', compact('post'));
 }
 public function save(Request $request)
 {
     $post = Post::findOrNew($request->get("id"));
     $post->fill($request->input())->save();
     return redirect('/post')->with('alert', ['message' => 'Post alterado com sucesso', 'type' => 'success', 'before' => null, 'after' => null]);
 }