覆盖由包设置的路由(Laravel 5.2)

时间:2016-06-01 04:00:48

标签: php laravel laravel-5

我正在使用laravel 5.2和sentinel包(rydurham/Sentinel) 该包自动设置一些路由,即:

Route::get('login', ['as' => 'sentinel.login', 'uses' => 'SessionController@create']);
Route::get('logout', ['as' => 'sentinel.logout', 'uses' => 'SessionController@destroy']);
Route::get('sessions/create', ['as' => 'sentinel.session.create', 'uses' => 'SessionController@create']);
Route::post('sessions/store', ['as' => 'sentinel.session.store', 'uses' => 'SessionController@store']);

为了添加我的自定义逻辑,我创建了一个新的会话控制器,并尝试覆盖执行以下操作的路由:

Route::get('login', ['as' => 'sentinel.login', 'uses' => 'AuthController@create']);
Route::get('sessions/create', ['as' => 'sentinel.session.create', 'uses' => 'AuthController@create']);
Route::post('sessions/store', ['as' => 'sentinel.session.store', 'uses' => 'AuthController@store']);

问题laravel的路由似乎有利于包路线。我可以注释掉包装中的路线,但是这会使更新变得痛苦 如何在不修改包的情况下覆盖路由? 谢谢!

1 个答案:

答案 0 :(得分:1)

您可以在config/sentinel.php

中停用Sentinel默认路由
/*
|--------------------------------------------------------------------------
| Default Routing
|--------------------------------------------------------------------------
|
| Sentinel provides default routes for its sessions, users and groups.
| You can use them as is, or you can disable them entirely.
|
*/
'routes_enabled' => true,