9

I want to change the auth process to use another view template. E.g. instead of resources/views/auth/register.blade.php it shall be used resources/views/register.blade.php.

But I struggle to find the code where this view is called.

The only place I found was in app/Services/Register but only if the validators fails. I need the place when the view is called per default.

Santosh Kumar
  • 1,756
  • 15
  • 24
jerik
  • 5,714
  • 8
  • 41
  • 80

4 Answers4

25

Laravel 5.6- I am extending Amarnasan's answer

In Laravel 5.6, there is no AuthController.php. Instead of that, there are 4 different controllers.

  • LoginController.php
  • RegisterController.php
  • ForgotPasswordController.php
  • ResetPasswordController.php

To override the view of any Auth controller, Just look for the trait that Auth controller is using. Then, Go to that trait file and check which method is returning the default view for the Auth controller.

To change the default view for login

add the following in LoginController.php

public function showLoginForm() {
   return view('auth.m-login');
}

To change the default view for Registration

add the following in RegisterController.php

public function showRegistrationForm() {
    return view('auth.m-register');
}

To change the default view for Forgot password

add the following in ForgotPasswordController.php

public function showLinkRequestForm(){
    return view('auth.passwords.m-email');
}

To change the default view for Reset password

add the following in ResetPasswordController.php

public function showResetForm(Request $request, $token = null){
    return view('auth.passwords.m-reset')->with(
        ['token' => $token, 'email' => $request->email]
    );
}
Santosh Kumar
  • 1,756
  • 15
  • 24
5

In AuthController, you can overwrite the method getRegister() method like this :

public function getRegister()
{
   return view('register');
}

Put this code in your AuthController.

Kiran Subedi
  • 2,244
  • 3
  • 17
  • 34
3

I think you are looking for the trait AuthenticatesAndRegistersUsers in file Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers.php used by the class AuthController in \App\Http\Controllers\Auth.php. Specifically, the register view of your example is called in function getRegister

Amarnasan
  • 14,939
  • 5
  • 33
  • 37
1

in the class AuthController put this :

protected $registerView = 'directory.auth.register';
Brandon Minnick
  • 13,342
  • 15
  • 65
  • 123
Manuel Temple
  • 703
  • 5
  • 5