OshJones's avatar

Route with 2 parameters

Can anybody help with my route problem?

I'm trying to create a route to a 'blog' but have a category and a subcategory in the url before it.

I've managed to create an example.com/category/slug URL, but I would like a example.com/category/subcategory/slug

Please be aware that the category and sub category will be loaded in dynamically and not hard coded.

Any feedback is greatly appreciated. Thanks a lot in advance.

0 likes
2 replies
topvillas's avatar
Level 46
Route::get('{category}/{subcategory}/{slug}', 'Controller@method');
1 like
OshJones's avatar

This is what I have for the 1st step in my route so to get the example.com/category

Route::get('insurance/{$category}', 'PagesController@getInsuranceCategory')->where('category', '[\w\d\-\_]+')->name('pages.category-single');

And in the Controller i have this

public function getInsuranceCategory($category){ return view('pages.category-single'); }

but i get a "sorry this page could not be found"

Please or to participate in this conversation.