How to change default Laravel Auth login view
In App\Http\Controllers\Auth\LoginController
define a fuction named showLoginForm()
as:
public function showLoginForm()
{
return view('custom.login');
}
It overrides the function showLoginForm
defined in the trait Illuminate\Foundation\Auth\AuthenticatesUsers
.
Note: In Laravel 5.3 the function name is changed from getLogin
to showLoginForm
.
Since the question was already answered I'll give the same example for the current version of Laravel.
If you're on Laravel 5.6 and up, this functionality should be put in
app/Http/Controllers/Auth/LoginController.php
public function showLoginForm()
{
return view('custom.login');
}
Also, if you would like to add a parameter to this, you can do so if you specify it in your web route like this:
Route::get('login/{page?}', 'Auth\LoginController@showLoginForm')->name('login');
Then you can do something like this:
public function showLoginForm($page = null)
{
if(isset($page)){
// do something
// example: return view('auth.login', compact('page'));
}
return view('auth.login');
}
Tip: if you don't have the LoginController in your project make sure you run
php artisan make:auth