How to change the default Laravel authentication routes such as Login and register to your own custom-defined routes.
/login to /signin.
I am using Laravel UI which comes with embedded authentication routes. These are called with Auth::routes(); in the routes/web.php file.
The best way to create your own custom route for login is to disable the default Laravel UI route
Auth::routes(['login' => false]);
Then define your own
Route::get('signin', 'App\Http\Controllers\Auth\LoginController@showLoginForm');
Route::post('signin', 'App\Http\Controllers\Auth\LoginController@login')->name('login'); Use the source as a template for controller and functions, by keeping the route named as login it will automatically be this custom route whenever a redirect to “login” occurs.
Now to change /register to /create
Auth::routes(['login' => false, 'register' => false]);
Route::get('create', 'App\Http\Controllers\Auth\RegisterController@showRegistrationForm');
Route::post('create', 'App\Http\Controllers\Auth\RegisterController@register')->name('register'); Make sure to run php artisan route:cache after editing routes.
A drained and empty Kennington reservoir images from a drone in early July 2024. The…
Merrimu Reservoir from drone. Click images to view larger.
Using FTP and PHP to get an array of file details such as size and…
Creating and using Laravel form requests to create cleaner code, separation and reusability for your…
Improving the default Laravel login and register views in such a simple manner but making…
Laravel validation for checking if a field value exists in the database. The validation rule…