Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5: override the default view for Registration page

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.

like image 928
jerik Avatar asked Oct 05 '15 07:10

jerik


1 Answers

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]
    );
}
like image 172
Santosh Kumar Avatar answered Oct 23 '22 04:10

Santosh Kumar