当我存储帖子时出现此错误
When I storing a post I get this error
MethodNotAllowedHttpException in RouteCollection.php line 219:
什么会导致这个问题??
What can cause this problem ??
Routes.php:
Routes.php:
Route::get('home', 'PostsController@index');
Route::get('/', 'PostsController@index');
Route::get('index', 'PostsController@index');
Route::get('posts', 'PostsController@index');
Route::get('post/{slug}/{id}', 'PostsController@show');
Route::get('posts/sukurti-nauja-straipsni', 'PostsController@create');
Route::patch('posts/store-new-post', 'PostsController@store');
Route::get('post/{slug}/{id}/edit', 'PostsController@edit');
Route::patch('posts/{slug}', 'PostsController@update');
Route::get('tags/{tags}', 'TagsController@show');
Route::get('categories/{categories}', 'CategoriesController@show');
// Authentication routes...
Route::get('auth/login', 'AuthAuthController@getLogin');
Route::post('auth/login', 'AuthAuthController@postLogin');
Route::get('auth/logout', 'AuthAuthController@getLogout');
// Registration routes...
Route::get('auth/register', 'AuthAuthController@getRegister');
Route::post('auth/register', 'AuthAuthController@postRegister');
我正在使用 Laravel 5.1,但我一天都想不通..
I'm using Laravel 5.1 and I can't figure this out for a day..
由于您将帖子更新的方法设置为 patch,请确保您打开您的表单以使用该方法:
Since you're setting the method on the post's update to be patch, be sure you open your form to use that method:
{!! Form::open(['method' => 'patch']) !!}
如果你没有使用 Form 类,你也可以确保有一个 隐藏在表单下面的名为 _method 的元素:
If you're not using the Form class, you can also just ensure there's a hidden element called _method underneath the form:
<input name="_method" type="hidden" value="PATCH">
同样,如果您通过 AJAX 发送此数据,只需在通过 POST 发送请求之前将 _method 键添加到设置为 'PATCH' 的有效负载中.某些浏览器(IE 7/8)不支持通过 XMLHttpRequest 的 PATCH HTTP
Similarly, if you're sending this data via AJAX, just add a _method key to the payload set to 'PATCH' before sending the request via POST. Some browsers (IE 7/8) do not support PATCH HTTP through XMLHttpRequest
您的另一个选择是更改您的路由以接受 POST 数据:
Your other option is to change your route to accept POST data instead:
Route::post('posts/store-new-post', 'PostsController@store');
Route::post('posts/{slug}', 'PostsController@update');
这篇关于RouteCollection.php 第 219 行中的 MethodNotAllowedHttpException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
按类别划分的 Magento 产品Magento products by categories(按类别划分的 Magento 产品)
资源被解释为图像但使用 MIME 类型 text/html 传输Resource interpreted as image but transferred with MIME type text/html - Magento(资源被解释为图像但使用 MIME 类型 text/html 传输 - Magen
Magento 中是否有客户帐户注册事件?Is there an event for customer account registration in Magento?(Magento 中是否有客户帐户注册事件?)
Magento addFieldToFilter:两个字段,匹配为 OR,而不是Magento addFieldToFilter: Two fields, match as OR, not AND(Magento addFieldToFilter:两个字段,匹配为 OR,而不是 AND)
“未找到错误 404"在 Magento 管理员登录页面quot;Error 404 Not Foundquot; in Magento Admin Login Page(“未找到错误 404在 Magento 管理员登录页面)
在 Magento 中获取订单增量 IDGet Order Increment Id in Magento(在 Magento 中获取订单增量 ID)