请教一下关于路由多重嵌套,控制器方法重复参数问题?
比如我的路由如下,商家->门店->商品
Route::group(['prefix' => 'merchants'], function() {
Route::group(['prefix' => '{merchant}/shops'], function() {
Route::group(['prefix' => '{shop}/products'], function() {
Route::get('/', function($merchant, $shop) {
});
Route::post('/', function($merchant, $shop) {
});
Route::get('/{product}/comments', function($merchant, $shop, $product) {
});
});
});
});
每个控制器都需要写$merchant和$shop参数,有没有什么方法能够省略掉这些参数,或者放到类里边,然后可以调用。
还有就是这种路由规划有没有什么问题,产品这些需要单独提取出来做路由合适呢,还是就是这种嵌套在“商家/门店”下面合适
推荐文章: