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

You could use regular expressions.

https://laravel.com/docs/5.2/routing

0

I think I solved it with this code:

Route::pattern('productId', '[0-9]*');

Route::pattern('slug', '[a-zA-Z-0-9]+');

Route::get('/{slug}-{productId}', function ($slug, $productId) { $product = App\Product::findOrFail($productId); return $product; });

Last updated 8 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.