title: How to write update query in laravel 5.2
body: <p>I am fetching data from the table to one form using laravel 5.2 for editing or updating existing data. But when i click on update button its not updating. Can anyone please help me to find out the mistake that i did in my code .
  My edit form is add.blade.php given below</p>
  
  <pre><code>   @extends('app')
  
  @section('content')
  
      &lt;div class="templatemo-content-wrapper"&gt;
          &lt;div class="container"&gt;
              &lt;ol class="breadcrumb"&gt;
                  &lt;li&gt;&lt;a href="{{ url("/") }}"&gt;&lt;font color="green"&gt;Home&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
                  &lt;li class="active"&gt;View/Edit Group&lt;/li&gt;
              &lt;/ol&gt;
              &lt;div class="row"&gt;
                  &lt;div class="col-md-8 col-md-offset-2"&gt;
                      &lt;div class="panel panel-success"&gt;
                          &lt;div class="panel-heading"&gt;View/Edit Group Information&lt;/div&gt;
                          &lt;div class="panel-body"&gt;
                              @if (count($errors) &gt; 0)
                                  &lt;div class="alert alert-danger"&gt;
                                      &lt;strong&gt;Whoops!&lt;/strong&gt; There were some problems with your input.&lt;br&gt;&lt;br&gt;
                                      &lt;ul&gt;
                                          @foreach ($errors-&gt;all() as $error)
                                              &lt;li&gt;{{ $error }}&lt;/li&gt;
                                          @endforeach
                                      &lt;/ul&gt;
                                  &lt;/div&gt;
                              @endif
  
                              &lt;form class="form-horizontal" role="form" method="POST" action="{{ url('group/update/') }}"&gt;
                                  &lt;input type="hidden" name="_token" value="{{ csrf_token() }}"&gt;
  @foreach($groups as $grp)
                                  &lt;div class="form-group"&gt;
                                      &lt;label class="col-md-4 control-label"&gt;Group ID&lt;/label&gt;
                                      &lt;div class="col-md-6"&gt;
  
                                          &lt;input type="text" class="form-control" name="userID" value="{{ ($grp-&gt;groupID)}}"&gt;
  
                                      &lt;/div&gt;
                                  &lt;/div&gt;
  
                                  &lt;div class="form-group"&gt;
                                      &lt;label class="col-md-4 control-label"&gt;Group Name&lt;/label&gt;
                                      &lt;div class="col-md-6"&gt;
                                          &lt;input type="text" class="form-control" name="description" value="{{ ($grp-&gt;description) }}" &gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
  
                                  &lt;div class="form-group"&gt;
                                      &lt;div class="col-md-6 col-md-offset-4"&gt;
                                          &lt;button type="submit" class="btn btn-warning"&gt;
                                              Update
                                          &lt;/button&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
  @endforeach
                              &lt;/form&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  @endsection
  </code></pre>
  
  <p>controller page GroupController.php is</p>
  
  <pre><code>public function edit($id)
  {
      try {
          //Find the user object from model if it exists
          $groups = DB::table('devicegroup')-&gt;where('groupID', '=', $id)-&gt;get();
          //$user = User::findOrFail($id);
          //Redirect to edit user form with the user info found above.
          return view('group.add')-&gt;with('groups', $groups);
  
  
      } catch (ModelNotFoundException $err) {
          //redirect to your error page
      }
  }
  
  // Update Group
  public function update(Request $request)
  {
      try {
          $data=DB::table('devicegroup')
              -&gt;where("groupID",$request['groupID'])
              -&gt;update(array("description"=&gt;$request['description']
                  ));
  
           $groups = DB::table('devicegroup')-&gt;simplePaginate(10);
          return view('group.groupAdmin')-&gt;with('groups', $groups);
  } catch (ModelNotFoundException $err) {
          //Show error page
      }
  
  }
  </code></pre>
  
  <p>and routes.php is</p>
  
  <pre><code>    Route::any('group/edit/{id}', 'GroupController@edit');
  Route::post('group/update', 'GroupController@update');
  </code></pre>
  
  <p>my model Group.php is</p>
  
  <pre><code>    &lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class Group extends Model
  {
  
      protected $table = 'devicegroup';
      /**
       * The attributes that are mass assignable.
       *
       * @var array
       */
      protected $fillable = [
          'groupID', 'description',
      ];
  
      /**
       * The attributes that should be hidden for arrays.
       *
       * @var array
       */
      protected $hidden = [
          //'password', 'remember_token',
      ];
  }
  </code></pre>