为什么用自己写的路由代替 Auth::routes () ?

教程中说

Auth::routes()

等同与

// Authentication Routes...
Route::get('login', 'Auth\LoginController@showLoginForm')->name('login');
Route::post('login', 'Auth\LoginController@login');
Route::post('logout', 'Auth\LoginController@logout')->name('logout');

// Registration Routes...
Route::get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
Route::post('register', 'Auth\RegisterController@register');

// Password Reset Routes...
Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
Route::post('password/reset', 'Auth\ResetPasswordController@reset');

为什么要自己重新写一遍下面这个复杂的路由代替 Auth::routes() 呢?

《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
KayuHo
最佳答案

作者好像有写啊,为了教学更加直观的体现啊。你可以直接用 Auth::routes()

6年前 评论
讨论数量: 5
KayuHo

作者好像有写啊,为了教学更加直观的体现啊。你可以直接用 Auth::routes()

6年前 评论
KayuHo

作者好像有写啊,为了教学更加直观的体现啊。你可以直接用 Auth::routes()

6年前 评论

应该可能是让大家更熟悉 'Auth::routes()' 的具体内容吧

5年前 评论

首先,这代码不是作者写的,而是框架自带的,只是封装在了Router.php中(有兴趣可以去看一下这个文件),这边只是作者把这段代码提出来了,我认为应该是让大家学习更直观吧。

5年前 评论

在注册页面,有route('login')和别的等 ,如何不写上,等下会有更多的人 问 ,这里是怎么来的,我路由没有写啊,也不说写清楚,

5年前 评论
JohnZhang

今天遇到了,有一种场景,比如我们内网的考试系统,希望只有登录,无需注册等等,这种情况下需要自定义route就很有用。再比如有的情况下我们基于奇怪的原因希望/auth/login等自定义路由,这样写也能派上用场。

4年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!