laravel route regular expression constraints

Solutions on MaxInterview for laravel route regular expression constraints by the best coders in the world

showing results for - "laravel route regular expression constraints"
Ahmed
11 Jan 2017
1Route::get('user/{name}', function ($name) {
2    //
3})->where('name', '[A-Za-z]+');
4
5Route::get('user/{id}', function ($id) {
6    //
7})->where('id', '[0-9]+');
8
9Route::get('user/{id}/{name}', function ($id, $name) {
10    //
11})->where(['id' => '[0-9]+', 'name' => '[a-z]+']);