美文网首页
(Auth::routes()是什么意思?)2020-04-07

(Auth::routes()是什么意思?)2020-04-07

作者: 浪子游剑 | 来源:发表于2020-04-07 05:35 被阅读0次

Auth::routes()
也可以写成
App::make('router')->auth();
这里路由定义文件在
/vendor/laravel/framework/src/Illuminate/Support/Facades

<?php

namespace Illuminate\Support\Facades;

/**
 * @see \Illuminate\Auth\AuthManager
 * @see \Illuminate\Contracts\Auth\Factory
 * @see \Illuminate\Contracts\Auth\Guard
 * @see \Illuminate\Contracts\Auth\StatefulGuard
 */
class Auth extends Facade
{
    /**
     * Get the registered name of the component.
     *
     * @return string
     */
    protected static function getFacadeAccessor()
    {
        return 'auth';
    }

    /**
     * Register the typical authentication routes for an application.
     *
     * @return void
     */
    public static function routes()
    {
        static::$app->make('router')->auth();
    }
}

static::$app->make('router')->auth();
实例化路由router调用auth方法

vendor\laravel\framework\src\Illuminate\Routing\Router.php
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');
        $this->post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail');
        $this->get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm');
        $this->post('password/reset', 'Auth\ResetPasswordController@reset');
    }

相关文章

网友评论

      本文标题:(Auth::routes()是什么意思?)2020-04-07

      本文链接:https://www.haomeiwen.com/subject/lyiwphtx.html