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

Question:

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

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

Doubt :

  • Is it possible to edit this view or route?
  • If yes, where?

Answer:

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

Washable 5.2

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

So:

protected $loginView = 'nome_da_minha_view';

In the trait source code called Illuminate\Foundation\Auth\AuthenticatesUsers , there is a method called showLoginForm , which is written like this:

/**
 * Show the application login form.
 *
 * @return \Illuminate\Http\Response
 */
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 loginView in the current class (in this context it would be AuthController ), the view used will be the one defined in this property, if the view also exists (according to the check of view()->exists() .

Laravel 5.3 and 5.4

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

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

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

Scroll to Top