Am trying to update a record in my database using an update button that is linked to a page where the update form is located but each time I click on the button, I get a 404 error (I think maybe the problem is that the page could not read the id of the requested post).
This is my route
Route::get('/pages/update/{id}','CallsController@edit');
Route::post('/pages/update/{id}','CallsController@update');
My CallsController
public function edit($id)
{
// $calls = Call::where('user_id', auth()->user()->id)->where('id', $id)->first();
// return view('pages.assignCall', compact('calls', 'id'));
$calls = Call::find($id);
return view('pages.assignCall')->with('calls', $calls);
}
public function update(Request $request, $id)
{
$calls = new Call();
$data = $this->validate($request, [
'call_details'=>'required',
]);
$data['id'] = $id;
$calls->updateCall($data);
return redirect('pages.pendingCalls');
}
I also have update.blade.php in the pages folder inside my views.
This is my update button
<a href="{{asset('/pages/update')}}>update</a>