Case 1: web.php
:
Route::get('foo/{id}', function () {
return 'Route 1';
});
Route::get('foo/bar', function () {
return 'Route 2';
});
Route::get('foo/bar', function () {
return 'Route 3';
});
When I browse to localhost/foo/bar
I got Route 1
which correct since the url match the first route.
Case 2: web.php
:
Route::post('foo/{id}', function () {
return 'Route 1';
});
Route::get('foo/bar', function () {
return 'Route 2';
});
Route::get('foo/bar', function () {
return 'Route 3';
});
When I browse to localhost/foo/bar
I got Route 3
.
My question is why i got Route 3
intead of Route 2
. Isn't logical to get Route 2
since the url match the second route first?! Why does Laravel continue to match the routes after match is found (route 2 in my case)?