Skip to content

Instantly share code, notes, and snippets.

@satheeshdragon
Created August 16, 2020 16:04
Show Gist options
  • Save satheeshdragon/de309465df6461efd17b059d902aa952 to your computer and use it in GitHub Desktop.
Save satheeshdragon/de309465df6461efd17b059d902aa952 to your computer and use it in GitHub Desktop.
Example 3-7. Regular expression route constraints
Route::get('users/{id}', function ($id) {
//
})->where('id', '[0-9]+');
Route::get('users/{username}', function ($username) {
//
})->where('username', '[A-Za-z]+');
Route::get('posts/{id}/{slug}', function ($id, $slug) {
//
})->where(['id' => '[0-9]+', 'slug' => '[A-Za-z]+']);
As you’ve probably guessed, if you visit a path that match
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment