Support the ongoing development of Laravel.io →
Requests
Last updated 2 years ago.
0

When looking for a route, Laravel looks through the Routes file in order for the FIRST Route it finds that matches the request.

Route::resource('city', 'CityController'); covers all route requests starting with 'city' so it should be placed AFTER any specific 'city/,,," routes.

There is no mention of this in the documentation that I could find.

Also, If it works, what is the problem?

Last updated 2 years ago.
0

mvolo is right.
Use patterns to prevent this.

Route::pattern('id', '[0-9]+');

Laravel will recognize that "names" is not a number and there won't be any match in the resourceful controller.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.