title: How to update data to database using controller in Laravel - Error Non-static method
body: <p>So Im trying to submit the edited data back to the database using the controller, yet I am getting the error <strong>"Non-static method Illuminate\Database\Eloquent\Model::update() should not be called statically"</strong> I think the code in the update function needs to be changed.</p>
  
  <p>web.php file</p>
  
  <pre><code>Route::post('/my-updated-routes', 'MyroutesController@update');
  </code></pre>
  
  <p>controller</p>
  
  <pre><code>public function update(Request $request)
  {
      Myroutes::update([ //updateing to myroutes table
          'start' =&gt; $request-&gt;start,
          'end' =&gt; $request-&gt;end,
          'waypoints' =&gt; implode(",", $request-&gt;waypoints)
      ]);
      return redirect('/my-saved-routes');
  }
  </code></pre>
  
  <p>show.blade.php</p>
  
  <pre><code>&lt;form method="post" action="{{ url('/my-updated-routes') }}"&gt;
      {{ csrf_field() }}
      &lt;div class="form-group"&gt;
          &lt;label&gt;Start Point&lt;/label&gt;
          &lt;input type="text" id="start" name="start" class="form-control" value="{{ $myroute-&gt;start }}" required/&gt;
      &lt;/div&gt;
  
      &lt;div class="form-group"&gt;
          &lt;label&gt;End Point&lt;/label&gt;
          &lt;input type="text" id="end" name="end" class="form-control" value="{{ $myroute-&gt;end }}" required/&gt;
      &lt;/div&gt;
  
      &lt;div&gt;
      &lt;label for="mode"&gt;Mode of Travel&lt;/label&gt;
          &lt;select id="mode" class="form-control" onchange="calculateAndDisplayRoute();"&gt;
            &lt;option value="DRIVING" name="driving"&gt;Driving&lt;/option&gt;
            &lt;option value="WALKING" name="walking"&gt;Walking&lt;/option&gt;
            &lt;option value="BICYCLING" name="cycling"&gt;Cycling&lt;/option&gt;
            &lt;option value="TRANSIT" name="public-transport"&gt;Public Transport&lt;/option&gt;
          &lt;/select&gt;
      &lt;/div&gt;
  
      &lt;p&gt;Note: Public Transport is only available for start and end points.&lt;/p&gt;
  
  
      &lt;div id="dynamicInput" class="form-group"&gt;
          &lt;label&gt;Additional Destinations&lt;/label&gt;
          &lt;input type="text" name="waypoints" class="form-control" autocomplete="on" value="{{ $myroute-&gt;waypoints }}"&gt;
      &lt;/div&gt;
  
      &lt;input type="button" class="btn btn-secondary" value="+" onClick="addInput('dynamicInput');" style="padding:0 10px;"&gt;               
      &lt;/br&gt;&lt;/br&gt;
      &lt;input type="button" id="calc-route" style="color:#2b2b2b" class="btn btn-light" value="Calculate Route"/&gt;
  
      &lt;input type="submit" id="update-route" class="btn btn-success" value="Update"/&gt;
      &lt;input type="button" class="btn btn-danger" value="Delete"/&gt;
  
  &lt;/form&gt; &lt;!-- end of form --&gt;    
  </code></pre>