在视图代码中
<a href="/vendoredit/{{$vendor->id}}"><h4 class="btn btn-default" title="Edit"><i class="fa fa-edit"></i></h4></a>
<a onclick="return confirm('Are you sure you want to delete this record?')" href="/vendordelete/{{$vendor->id}}"><h4 class="btn btn-danger" title="delete"><i class="fa fa-trash-o"></i></h4></a>
在route.php中
Route::get('/vendoredit/{id}','VendorslistController@edit');
Route::put('/vendordelete/{id}','VendorslistController@delete');
当我点击编辑或删除按钮时,它会显示以下错误:
(1/1)RouteCollection.php中的NotFoundHttpException(第179行)
在RouteCollection-&gt;匹配(对象(请求))
在Router.php(第546行)
在Router-&gt; findRoute(对象(请求))
在Router.php(第525行)中
答案 0 :(得分:0)
您的HTML代码应为:
<a href="{{url('/vendoredit/'.$vendor->id)}}"><h4 class="btn btn-default" title="Edit"><i class="fa fa-edit"></i></h4></a>
<a onclick="return confirm('Are you sure you want to delete this record?')" href="{{url('/vendordelete/'.$vendor->id)}}"><h4 class="btn btn-danger" title="delete"><i class="fa fa-trash-o"></i></h4></a>
答案 1 :(得分:0)
尝试使用route()函数
命名路由并连接到路由的链接Route::get('/vendor/{id}/edit','VendorslistController@edit')->name('vendor.edit');
Route::delete('/vendor/{id}','VendorslistController@delete')->('vendor.delete');
在你的观点中
<a href="{{route('vendor.edit',$vendor->id)}}"></a>
我建议你阅读Laravel关于路由的文件