How to Use a Parameter Other than the User ID in a Route in Laravel
In this lesson, we will see how to use a parameter other than the user ID in a route in Laravel, in some cases you may wish to retrieve data from Eloquent models using a column other than ID so how we can do that?
Customizing the column
To do that, you need to specify the column in the route parameter definition:
use App\Models\User;
Route::get('user/{user:email}', [UserController::class, 'getUserByEmail'])->name('fetch.user');