我似乎无法在/ cars / {id?} / modify
中发布数据错误:
[
{
"name": "test2",
"IDNO": "ff2222211",
"data_cnt": 1
},
{
"name": "qweee",
"IDNO": "ff2222",
"data_cnt": 2
},
{
"name": "fsdfasdf",
"IDNO": "ddaaa",
"data_cnt": 1
},
{
"name": "123",
"IDNO": "U120000005",
"data_cnt": 1
}
]
路线:
in RouteCollection.php line 219 at RouteCollection->methodNotAllowed(array('POST')) in RouteCollection.php line 206
at RouteCollection->getRouteForMethods(object(Request), array('POST')) in RouteCollection.php line 158
HTML:
Route::get('/', 'PagesController@home');
Route::get('/about', 'PagesController@about');
Route::get('/contact', 'PagesController@contact');
Route::get('/cars', 'CarsController@index');
Route::get('/cars/{id?}/edit', 'CarsController@edit');
Route::post('/cars/{id?}/modify', 'CarsController@update');
Route::get('/cars/add', 'CarsController@add');
Route::post('/cars/add', 'CarsController@store');
Route::get('/cars/{id?}/delete','CarsController@destroy');
答案 0 :(得分:0)
在laravel中没有更新方法/路线这样的东西。对于编辑,您应该使用PUT
。
您可以通过更改两件事来解决问题:
您的路由方法
Route::post('/cars/{id?}/modify', 'CarsController@update');
到
Route::put('/cars/{id?}/modify', 'CarsController@update');
并以您的形式
<input name="_method" type="hidden" value="UPDATE">
到
<input name="_method" type="hidden" value="PUT">
答案 1 :(得分:0)
只需删除此行
即可<input name="_method" type="hidden" value="UPDATE">
或制作如下所示的路线
Route::update('/cars/{id?}/modify', 'CarsController@update');