Laravel新手在这里,我想在没有资源控制器的情况下在Laravel中创建更新路径。 我有编辑路线
Route::get('/indexedit','PagesController@indexedit')->middleware('user');
在那里,有一个表格,内容如下
<form class="col s12" method="POST" action="indexedit/{{ $val->id }}" >
{{ method_field('PUT') }}
{{ csrf_field() }}
有两个输入字段和一个用于提交的按钮。我创建了一个更新的路径
Route::post('indexedit/{$id}', 'PagesController@update');
但是当我提交时,它表示没有找到路线。 RouteCollection.php第161行中的NotFoundHttpException:
答案 0 :(得分:3)
首先,您不需要在路线上签名Documentation):
TStringList
其次,我会在url()方法中包含动作url以防万一:
Route::post('indexedit/{id}', 'PagesController@update');
答案 1 :(得分:0)
您应该从更新记号中使用put
,而不是post
。
这不行:
Route::post('indexedit/{id}', 'PagesController@update');
使用此:
Route::put('indexedit/{id}', 'PagesController@update');