Regular Expression Constraints: Global Constraints
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
Route::pattern('id', '[0-9]+');
parent::boot();
}
/* web.php
Once the pattern has been defined, it is automatically applied to all routes using that parameter name:
*/
Route::get('user/{id}', function ($id) {
// Only executed if {id} is numeric...
});