路线Sl总是被查询-Laravel 5.4

时间:2018-07-01 19:03:07

标签: laravel-5.4

这是我的 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]的查询结果。

1 个答案:

答案 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');