Laravel嵌套路由段链接

时间:2019-03-11 09:12:36

标签: laravel routes slug

我想使用可弯曲的结构来进行路段和即时通讯。定义链接时,我使用SeoServiceProvider。

 foreach($categories as $category){

  $router->get($category['path'], 'App\Http\Controllers\User\CategoryController@index')
    ->defaults('category', $category['id'])
    ->name($category['path'])
    ->middleware('web');
};

通过这种方式,类别结构起作用。

site.com/category
site.com/category/subcategory
site.com/category/subcategory/subsubcategory

我要建立以下结构

site.com/product
site.com/category/product
site.com/category/subcategory/product
site.com/category/subcategory/subsubcategory/product

我需要对这个嵌套循环进行操作,有没有简单的方法可以做到这一点。

0 个答案:

没有答案