I'm building a twitter-ish website and I'm having a problem with routing:
- this code will bring the user to the profile page of the person with the given id.
Route::get('/profile/{id}', 'ProfileController@show')->name('profile.show');
- this code will bring the user to the profile page of the person with the given username.
Route::get('/profile/{username}', 'ProfileController@show')->name('profile.show');
- and finally, this code will bring the user to the profile page of the person with the given email.
Route::get('/profile/{email}', 'ProfileController@show')->name('profile.show');
I mean all these three URLs will show the user the same page:
example.com/profile/1
example.com/profile/rahimi0151
example.com/profile/rahimi0151@gmail.com
my question is: is there a way to merge all these routes? like below:
Route::get('/profile/{id|username|email}', 'ProfileController@show')->name('profile.show');