Laravel Auth::routes() 包含的路由列表
admin 阅读:128 2024-03-02
若你使用 Laravel UI 扩展,那么你可能想知道Auth::routes()定义之后真正的路由都有什么?
查看 /vendor/laravel/ui/src/AuthRouteMethods.php 文件源码可以看到所有的路由列表。
public function auth()
{
return function ($options = []) {
// Authentication Routes...
$this->get('login', 'AuthLoginController@showLoginForm')->name('login');
$this->post('login', 'AuthLoginController@login');
$this->post('logout', 'AuthLoginController@logout')->name('logout');
// Registration Routes...
if ($options['register'] ?? true) {
$this->get('register', 'AuthRegisterController@showRegistrationForm')->name('register');
$this->post('register', 'AuthRegisterController@register');
}
// Password Reset Routes...
if ($options['reset'] ?? true) {
$this->resetPassword();
}
// Password Confirmation Routes...
if ($options['confirm'] ?? class_exists($this->prependGroupNamespace('AuthConfirmPasswordController'))) {
$this->confirmPassword();
}
// Email Verification Routes...
if ($options['verify'] ?? false) {
$this->emailVerification();
}
};
}根据源码可知我们还可以使用参数来启用或者禁用指定路由:
Auth::routes([
'login' => true,
'logout' => true,
'register' => true,
'reset' => true, // for resetting passwords
'confirm' => false, // for additional password confirmations
'verify' => false, // for email verification
]);声明
1、部分文章来源于网络,仅作为参考。 2、如果网站中图片和文字侵犯了您的版权,请联系1943759704@qq.com处理!

