SubstituteBindings Middleware没有区分slug和自定义路由名称

时间:2017-01-10 21:35:23

标签: php laravel middleware

我有所有这些路线:

Route::resource('tournaments', 'TournamentController');
Route::get('/tournaments/deleted', 'TournamentController@getDeleted'); 

当我访问

/tournaments/deleted 

我得到了

Model Not Found 

in

SubstituteBindings Middleware 
认为删除的是我的锦标赛slu ..

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

解决方案是首先定义getDeleted Route,然后定义ressource:

工作:

Route::get('/tournaments/deleted', 'TournamentController@getDeleted')->name('getDeleted'); // Already has auth middleware
Route::resource('tournaments', 'TournamentController');

不工作:

Route::resource('tournaments', 'TournamentController');
Route::get('/tournaments/deleted', 'TournamentController@getDeleted')->name('getDeleted'); // Already has auth middleware