Support the ongoing development of Laravel.io →
Requests Session Views

so i want to expand my site to have like region site, so when user open my site it will be ask to select which region he/she interested into and lets just say he interesting in London, then the site will generate a webpage that already all content related to that region...

i tried to just do the same way i create administrator page by group them in this route

Route::group(array('prefix'=>'admins','before' => 'auth'),function(){
    Route::resource('partner','AdminPartnerController',array('except' => array('show')));
    Route::get('partner/index_kategori/{id}',array(
        'as' => 'admins.partner.index_kategori',
        'uses' => 'AdminPartnerController@index_kategori'
});

but it's mean that i need to create a different controller function for each region i gonna create, so it's not very efficient.

what comes to my mind is just like making

www.websiteadress.com/region

so how i can catch that "/region" and add that value into each my function in controller? how to build that kind of routes?

update:

to make it more easily to understand, what become my problem is like i have this normal route:

Route::get('product/{id}',array( 'as' => 'product','uses' => 'PublicController@product'));

what this route do is pretty straight foward, when i type

www.websiteadress.com/product/12

it will open the product page for number 12, so my problem is if i add like this

www.websiteadress.com/Asia/product/12 

how i make my PublicController to catch Asia and later in my product function i will just process that..?

Last updated 2 years ago.
0

Something like Route::get('{region?}/product/{id}',array( 'as' => 'product','uses' => 'PublicController@product'));

0

Sign in to participate in this thread!

Eventy

Your banner here too?

t0n1zz t0n1zz Joined 8 Oct 2014

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.

© 2025 Laravel.io - All rights reserved.