【发布时间】:2016-09-19 19:51:24
【问题描述】:
所以我想扩展我的站点以拥有类似的区域站点,因此当用户打开我的站点时,系统会要求选择他/她感兴趣的区域,然后说他对伦敦感兴趣,然后该站点将生成一个已经与该地区相关的所有内容的网页...
我尝试以与创建管理员页面相同的方式通过在此路线中对它们进行分组
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'
});
但这意味着我需要为要创建的每个区域创建不同的控制器功能,所以效率不高。
我想到的就像制作
www.websiteadress.com/region
那么我如何才能捕获那个“/region”并将该值添加到我在控制器中的每个函数中?如何建立那种路线?
更新:
为了更容易理解,我的问题是我有这条正常路线:
Route::get('product/{id}',array( 'as' => 'product','uses' => 'PublicController@product'));
当我输入时,这条路线的作用非常直接
www.websiteadress.com/product/12
它将打开 12 号的产品页面,所以我的问题是如果我像这样添加
www.websiteadress.com/Asia/product/12
我如何让我的 PublicController 赶上亚洲,然后在我的产品功能中我将只处理它..?
【问题讨论】:
-
也许可以这样制作路线:
Route::get('product/{country}/{id}',array( 'as' => 'product','uses' => 'PublicController@product'));