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