I am using Laravel 5 and working on my local. I made a route with a parameter of {id} and another route with a specific name like so :
Route::get(\'contacts/
Although the accepted answer is perfectly fine, usually a parameter is used more than once and thus you might want to use a DRY approach by defining a pattern in your boot function in the RouteServiceProvider.php file located under app/Providers
(Laravel 5.3 and onwards):
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
Route::pattern('id', '[0-9]+');
parent::boot();
}
This way, whereever you use your {id} parameter the constraints apply.