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

You can do

Route::get('location/category/subcategory/item', array('uses' => 'RestaurantController@example');

and for category

Route::get('location/category/subcategory', array('uses' => 'CategoryController@example');
Last updated 2 years ago.
0

Small correction on the previous comment:

Route::get('{location}/{category}/{subcategory}/{item}', function($location, $category, $subcategory, $item) {
    echo "Restaurant";
    var_dump($location, $category, $subcategory, $item);
});

Route::get('{location}/{category}/{subcategory}', function($location, $category, $subcategory) {
    echo "Category";
    var_dump($location, $category, $subcategory);
});

will give you something a bit more dynamic.

Last updated 2 years ago.
0

Thanks for that, I really appreciate the help. I was concerned that

{location}/{category}/{subcategory}/{item}

contains

{location}/{category}/{subcategory}

but the routes obviously have to match exactly.

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