Laravel:我在哪里重写Router.php中的auth()?

时间:2017-08-13 08:51:50

标签: laravel

auth()中有一个\vendor\laravel\framework\src\Illuminate\Routing\Router.php方法, 我想用auth()方法重写一些路由。

问题:

我在哪里放置我编辑的auth()方法? 如果在Router.php中对其进行修改,则会在composer update之后重置。

1 个答案:

答案 0 :(得分:2)

您永远不应更改vendor/文件夹中的代码。

调用Auth:routes()routes/web.php文件中,将为身份验证部分生成所有9条路由。我认为没有办法告诉方法你只想生成一些路由。相反,您可以手动设置它们并按照您的意愿更改每条路线:

// Login Routes...
    Route::get('login', ['as' => 'login', 'uses' => 'Auth\LoginController@showLoginForm']);
    Route::post('login', ['as' => 'login.post', 'uses' => 'Auth\LoginController@login']);
    Route::post('logout', ['as' => 'logout', 'uses' => 'Auth\LoginController@logout']);

// Registration Routes...
    Route::get('register', ['as' => 'register', 'uses' => 'Auth\RegisterController@showRegistrationForm']);
    Route::post('register', ['as' => 'register.post', 'uses' => 'Auth\RegisterController@register']);

// Password Reset Routes...
    Route::get('password/reset', ['as' => 'password.reset', 'uses' => 'Auth\ForgotPasswordController@showLinkRequestForm']);
    Route::post('password/email', ['as' => 'password.email', 'uses' => 'Auth\ForgotPasswordController@sendResetLinkEmail']);
    Route::get('password/reset/{token}', ['as' => 'password.reset.token', 'uses' => 'Auth\ResetPasswordController@showResetForm']);
    Route::post('password/reset', ['as' => 'password.reset.post', 'uses' => 'Auth\ResetPasswordController@reset']);
});