HB_BHF
10027
20
Laravel

How to create URL slugs in Laravel

Posted 2 years ago by HB_BHF

Right now I have a routes with an ID as a wildcard.

Route::get('detailPage/{id}', '[email protected]');

How can I create URLs with slugs (i.e. like on stackoverflow)? I have a table of campaigns with ID and product name. How can I use this product name? So, instead of

myapp.com/detailPage/12345

I have this -

myapp.com/detailPage/Microsoft-Xbox-360

Of course, 12345 is an ID of Microsoft Xbox 360...

Please sign in or create an account to participate in this conversation.