Example #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(PostRequest $request, $id)
 {
     //dd('we are here');
     if (isset($_POST['update'])) {
         // $this->validate($request,['title' => 'required','postdesc' => 'required|min:2','istate'=>'required']);
         $post = new Post();
         $post = Post::find($id);
         $post->title = $request->input('title');
         $post->body = $request->input('postdesc');
         $post->status = $request->input('istate');
         $post->save();
         $request->session()->flash('alert-info', 'Post is successfully updated!');
         return redirect('posts');
         // $posts=Post::all();
         // return view('post.index', ['posts'=>$posts]);
     }
 }