讨论数量:
可以一点一点找到
Auth::routes();
这个是调用的是一个 叫 Auth
的 alias
,见 config/app.php
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
找到 Illuminate\Support\Facades\Auth
这个门面,可以看到里面有个 routes
方法
public static function routes()
{
static::$app->make('router')->auth();
}
可以看到,它实例化了一个 Router
类,然后再找到这个 Router
类,Illuminate/Routing/Router.php
找到 Illuminate/Routing/Router.php
, 里面有个 auth
方法,见内容,应该就明白了吧
public function auth()
{
// Authentication Routes...
$this->get('login', 'Auth\LoginController@showLoginForm')->name('login');
$this->post('login', 'Auth\LoginController@login');
$this->post('logout', 'Auth\LoginController@logout')->name('logout');
// Registration Routes...
$this->get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
$this->post('register', 'Auth\RegisterController@register');
// Password Reset Routes...
$this->get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
$this->post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
$this->get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
$this->post('password/reset', 'Auth\ResetPasswordController@reset');
}
因为命令的使用位置不同,将 $this->
换成 Route::
就可以了
可以一点一点找到
Auth::routes();
这个是调用的是一个 叫 Auth
的 alias
,见 config/app.php
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
找到 Illuminate\Support\Facades\Auth
这个门面,可以看到里面有个 routes
方法
public static function routes()
{
static::$app->make('router')->auth();
}
可以看到,它实例化了一个 Router
类,然后再找到这个 Router
类,Illuminate/Routing/Router.php
找到 Illuminate/Routing/Router.php
, 里面有个 auth
方法,见内容,应该就明白了吧
public function auth()
{
// Authentication Routes...
$this->get('login', 'Auth\LoginController@showLoginForm')->name('login');
$this->post('login', 'Auth\LoginController@login');
$this->post('logout', 'Auth\LoginController@logout')->name('logout');
// Registration Routes...
$this->get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
$this->post('register', 'Auth\RegisterController@register');
// Password Reset Routes...
$this->get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
$this->post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
$this->get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
$this->post('password/reset', 'Auth\ResetPasswordController@reset');
}
因为命令的使用位置不同,将 $this->
换成 Route::
就可以了
可以一点一点找到
Auth::routes();
这个是调用的是一个 叫Auth
的alias
,见config/app.php
找到
Illuminate\Support\Facades\Auth
这个门面,可以看到里面有个routes
方法可以看到,它实例化了一个
Router
类,然后再找到这个Router
类,Illuminate/Routing/Router.php
找到
Illuminate/Routing/Router.php
, 里面有个auth
方法,见内容,应该就明白了吧因为命令的使用位置不同,将
$this->
换成Route::
就可以了