I want to override /login
route to /admin/login
. In web.php
I tried
//Auth::routes(); Route::get('login', ['as' => 'auth.login', 'uses' => 'App\Modules\Admin\Controllers\AdminUserController@loginAdminUser'])->name('login');
But it is still showing Laravel default login form. How can I do this?
When you call Auth::routes() , following routes will be registered. basically delete Auth::routes() in your route file or overwrite default Laravel auth routes in your route file. Any further help, you must to give more information about the thing you'd like to achieve.
Removing the routes Quite simply you just need to copy the routes you want to use into you routes/web. php file and ditch the rest. You'll also need to replace $this-> with Route:: . Quite simply, you can now remove Auth::route() from your routes file and just leave behind the authentication and password reset routes.
Auth::routes() is just a helper class that helps you generate all the routes required for user authentication. You can browse the code here https://github.com/laravel/framework/blob/5.3/src/Illuminate/Routing/Router.php instead.
For the googlers, here is a full list of routes that are getting generated by Auth::routes();
in Laravel >= 5.4
// Authentication Routes... Route::get('login', [ 'as' => 'login', 'uses' => 'Auth\LoginController@showLoginForm' ]); Route::post('login', [ 'as' => '', 'uses' => 'Auth\LoginController@login' ]); Route::post('logout', [ 'as' => 'logout', 'uses' => 'Auth\LoginController@logout' ]); // Password Reset Routes... Route::post('password/email', [ 'as' => 'password.email', 'uses' => 'Auth\ForgotPasswordController@sendResetLinkEmail' ]); Route::get('password/reset', [ 'as' => 'password.request', 'uses' => 'Auth\ForgotPasswordController@showLinkRequestForm' ]); Route::post('password/reset', [ 'as' => 'password.update', 'uses' => 'Auth\ResetPasswordController@reset' ]); Route::get('password/reset/{token}', [ 'as' => 'password.reset', 'uses' => 'Auth\ResetPasswordController@showResetForm' ]); // Registration Routes... Route::get('register', [ 'as' => 'register', 'uses' => 'Auth\RegisterController@showRegistrationForm' ]); Route::post('register', [ 'as' => '', 'uses' => 'Auth\RegisterController@register' ]);
php artisan route:list
will return
+--------+----------+------------------------+------------------+------------------------------------------------------------------------+--------------+ | Domain | Method | URI | Name | Action | Middleware | +--------+----------+------------------------+------------------+------------------------------------------------------------------------+--------------+ | | GET|HEAD | login | login | App\Http\Controllers\Auth\LoginController@showLoginForm | web,guest | | | POST | login | | App\Http\Controllers\Auth\LoginController@login | web,guest | | | POST | logout | logout | App\Http\Controllers\Auth\LoginController@logout | web | | | POST | password/email | password.email | App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail | web,guest | | | GET|HEAD | password/reset | password.request | App\Http\Controllers\Auth\ForgotPasswordController@showLinkRequestForm | web,guest | | | POST | password/reset | password.update | App\Http\Controllers\Auth\ResetPasswordController@reset | web,guest | | | GET|HEAD | password/reset/{token} | password.reset | App\Http\Controllers\Auth\ResetPasswordController@showResetForm | web,guest | | | GET|HEAD | register | register | App\Http\Controllers\Auth\RegisterController@showRegistrationForm | web,guest | | | POST | register | | App\Http\Controllers\Auth\RegisterController@register | web,guest | +--------+----------+------------------------+------------------+------------------------------------------------------------------------+--------------+
You can also try this one.
// Replace admin with whatever prefix you need Route::group(['prefix' => 'admin'], function () { Auth::routes(); });
You can see list of routes by following command.
php artisan route:list
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With