【发布时间】:2020-09-04 02:07:26
【问题描述】:
我使用 laravel 7 并在数据库中存储以下树结构:
目录表:
category1
--category11
--category12
----category121
----category122
--category13
文章表:
news
--news1
--news2
基本的 Laravel 路由看起来像:
Route::get('category/{id}', 'categoryController@show');
Route::get('news/{id}', 'newsController@show');
但在这种情况下,每个目录的 URL 都需要“类别”url 的段,并且 每个新的 URL 都需要“news” url 的段
如何使用 Laravel Routes 路由以下 url:
http://sitename.com/category1
http://sitename.com/category1/category11
http://sitename.com/category1/category12/category121
http://sitename.com/news
http://sitename.com/news/news1
?
【问题讨论】: