I have a route in my project like below :
Route::get('/product/{category}/{all}/{name}-{id}.html', ['as' => 'product.single', 'uses' => 'ProductController@single'])->where('id', '[0-9]+');
so here is the problem , as a tradition we put slug in url( and then id after that ) , but this way some of our routes will get confuse in id section, here is a example : /product/gold/women-gold/one-special-167.html because of ((-)) in the url laravel think special-167 is the id although it's not. so is there any reasonable way to get around this problem?
put the {id} first (and then {name}) in your route and in your method at the same time:
Route::get('/product/{category}/{all}/**{id}**-**{name}**.html', ['as' => 'product.single', 'uses' => 'ProductController@single'])->where('id', '[0-9]+');
Please try enable - character for name
Route::get('/product/{category}/{all}/{name}-{id}.html', ['as' => 'product.single', 'uses' => 'ProductController@single'])->where(['id' => '[0-9]+','name' => '[a-zA-Z-]+']);
You can easily replace id and name in the route or devide them /