Laravel5.5 Auth::routes();ってなに?

認証系のことを調べているとroute/web.phpに

Auth::routes();

このメソッドがよく記述されているが
これは

vendor/laravel/framework/src/Illuminate/Routing/Router.php
に記述されているauthメソッドを呼び出してるとのこと。
これではじめから用意されているuser系のは認証のルーティングは記述する必要がないんだな〜

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');
}

急ぎでWEBアプリを作らなくてはいけなくてネットの情報をそのまま使って
このAuth::routes();もよく調べもせず必要なんだなくらいで使っていたけど
やっぱりわからないことをは全部調べていった方がいいんだなと再確認。

参考文献
https://teratail.com/questions/106720

シェアする

  • このエントリーをはてなブックマークに追加

フォローする