You could use regular expressions.
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; });
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community