这是一组控制器的名单:MethodNotAllowedHttpException,重定向到404
Route::group([
'prefix' => 'some-prefix',
], function() {
Route::get('/', '[email protected]')->name('some-prefix');
Route::post('/get', '[email protected]')->name('some-prefix.get');
Route::get('/getall/{type}', '[email protected]')->name('some-prefix.getall');
Route::get('/create', '[email protected]')->name('some-prefix.create');
Route::post('/', '[email protected]')->name('some-prefix.store');
Route::get('/edit', '[email protected]')->name('some-prefix.edit');
Route::get('/{id}/edit/', '[email protected]')->name('some-prefix.edit');
Route::put('/{id}', '[email protected]')->name('some-prefix.update');
Route::get('/cambiarestado/{id}', '[email protected]')->name('some-prefix.cambiarestado');
});
我想,当我键入URL重定向到一个404错误:
http://myapp.com/some-prefix/ANYTHING-that-doesnt-match
这里是当我下一个错误:
(1/1) MethodNotAllowedHttpException
in RouteCollection.php (line 251)
at RouteCollection->methodNotAllowed(array('PUT'))
in RouteCollection.php (line 238)
at RouteCollection->getRouteForMethods(object(Request), array('PUT'))
in RouteCollection.php (line 176)
我把我的failOrFind
和store
内edit
种方法在我的控制器,这样我就可以redict到404条路线,如:
http://myapp.com/some-prefix/9999/edit
其中值9999
不存在,但我怎么能做到什么,我问?
什么是@ myController的更新和@ myController的编辑的代码?由于这些接受一个动态参数,你应该在那里处理404。 – Devon