How to edit the routes created by the make: auth command?

Posted on

Question :

I have a project in Laravel where I used the make:auth command to create the views , routes, controllers and etc from a registration form.

I need to change the view that is used by default in login to a view that I created the hand.

Doubt :

  • Can you edit this view or route?
  • If yes, where?

Answer :

In this particular case of changing the views you will want to follow the recommendation of the friend @Wallace Maxters. This is the recommended way. 😉

In the event that you need to customize the routes, you can simply comment on the Auth::routes() line of the routes/web.php file and manually declare the routes by following the model of how they were declared (I am using Laravel 5.4 as a reference):

// Authentication Routes...
$this->get('login', 'AuthLoginController@showLoginForm')->name('login');
$this->post('login', 'AuthLoginController@login');
$this->post('logout', 'AuthLoginController@logout')->name('logout');

// Registration Routes...
$this->get('register', 'AuthRegisterController@showRegistrationForm')->name('register');
$this->post('register', 'AuthRegisterController@register');

// Password Reset Routes...
$this->get('password/reset', 'AuthForgotPasswordController@showLinkRequestForm')->name('password.request');
$this->post('password/email', 'AuthForgotPasswordController@sendResetLinkEmail')->name('');
$this->get('password/reset/{token}', 'AuthResetPasswordController@showResetForm')->name('password.reset');
$this->post('password/reset', 'AuthResetPasswordController@reset');

In order not to change anything in the code, you just have to keep the names of the routes and keep the same URL on the routes that repeat the URL, so you can for example translate the URL login to entrar since you do this on both the GET route and the POST route.

In general, you do not need to change the methods that the routes point to since you can overload them directly on the classes that they depend on. 😉


This will depend on the version of Laravel you are using.

Laravel 5.2

You need to add the property $loginView to class AuthController .


protected $loginView = 'nome_da_minha_view';

In the source code of trait called IlluminateFoundationAuthAuthenticatesUsers , there is a method called showLoginForm , which is written like this:

 * Show the application login form.
 * @return IlluminateHttpResponse
public function showLoginForm()
    $view = property_exists($this, 'loginView')
                ? $this->loginView : 'auth.authenticate';

    if (view()->exists($view)) {
        return view($view);

    return view('auth.login');

Note that if the loginView property exists in the current class (in this context it would be AuthController ), the view used will be the one defined in this property, if view also exists (according to the view()->exists() check).

Laravel 5.3 and 5.4

You simply need to override the method named showLoginForm in the authentication class and return to view desired.

  public function showLoginForm()
        return view('minha_view_personalizada');

There is yet another hint, which is to create the method called getLogin returning view . It will have the same effect as above with showLoginForm .


Leave a Reply

Your email address will not be published. Required fields are marked *