這是一組控制器的名單: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