Laravel 5: override the default view for Registration page

jerik picture jerik · Oct 5, 2015 · Viewed 8.9k times · Source

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.

Answer

Santosh Kumar picture Santosh Kumar · Jul 9, 2018

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