这是我的 web.php 文件:
Route::get('/items', 'ItemsController@index');
Route::get('/items/create', 'ItemsController@create');
Route::get('/items/{item}', 'ItemsController@show');
Route::post('/items', 'ItemsController@store');
Route::delete('/items/{item}', 'ItemsController@destroy');
Route::get('/items/deleted', 'DeletedItemsController@index');
如何防止 / items / deleted 子句被视为通配符?
NotFoundHttpException 没有对模型[App \ Item]的查询结果。
答案 0 :(得分:1)
将/items/deleted
路由定义放在通配符上方:
Route::get('/items', 'ItemsController@index');
Route::get('/items/create', 'ItemsController@create');
Route::get('/items/deleted', 'DeletedItemsController@index');
Route::get('/items/{item}', 'ItemsController@show');
Route::post('/items', 'ItemsController@store');
Route::delete('/items/{item}', 'ItemsController@destroy');