2017-09-28 2 views

答えて

3

Auth::routes()またはRoute::auth()を使用すると同等です。

$app->make('router')ちょうどない Routeファサードよう Illuminate\Routing\Routerインスタンスを返し
/** 
* Register the typical authentication routes for an application. 
* 
* @return void 
*/ 
public static function routes() 
{ 
    static::$app->make('router')->auth(); 
} 

Auth::routes() Infactはとして定義されます。 Illuminate\Routing\Router.phpに見られるような

1

Route::auth()は(次のルートを作成します。あなたが見ることができるように、第二の

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

/** 
* Register the typical authentication routes for an application. 
* 
* @return void 
*/ 
public function auth() 
{ 
    // Authentication Routes... 
    $this->get('login', 'Auth\[email protected]')->name('login'); 
    $this->post('login', 'Auth\[email protected]'); 
    $this->post('logout', 'Auth\[email protected]')->name('logout'); 

    // Registration Routes... 
    $this->get('register', 'Auth\[email protected]')->name('register'); 
    $this->post('register', 'Auth\[email protected]'); 

    // Password Reset Routes... 
    $this->get('password/reset', 'Auth\[email protected]')->name('password.request'); 
    $this->post('password/email', 'Auth\[email protected]')->name('password.email'); 
    $this->get('password/reset/{token}', 'Auth\[email protected]')->name('password.reset'); 
    $this->post('password/reset', 'Auth\ResetPas[email protected]'); 
} 

Auth::routes()は、次の関数を(Illuminate\Support\Facades\Auth.phpに見られるような)を呼び出しますメソッドは、最初のRouterクラスのインスタンスを作成し、auth()関数を呼び出します。最後に、2つのメソッドに違いはありません。私は個人的にはRoute::auth()を使ってアドバイスしています。それは "デフォルト"の実装のようです。

関連する問題