我希望我的网址有两种可能性:
如果只有第一个网址的内容我想使用SectionController,如果有第二个网址的内容我想使用FurnitureController。现在,如果我只将/ en / section / 1放入我的网址,我会收到此错误:
缺少[路线:app.furniture.get] [URI:{lang} / section / {id_section} / furniture / {id}]
所需的参数
我想知道是否有办法做到这一点。这就是我现在所拥有的:
Route::group(["prefix" => "/{lang}"], function() {
Route::group(["prefix" => "section"], function() {
// Get a section
Route::get("{id}", [
"uses" => "SectionController@get",
"as" => "app.section.get"
]);
// Get a furniture
Route::get("{id_section}/furniture/{id}", [
"uses" => "FurnitureController@get",
"as" => "app.furniture.get"
]);
});
});
答案 0 :(得分:0)
您可以使用群组中的ID。
Route::group(["prefix" => "/{lang}"], function() {
Route::group(["prefix" => "section/{id}"], function() {
// Get a section
Route::get("", [
"uses" => "SectionController@get",
"as" => "app.section.get"
]);
// Get a furniture
Route::get("furniture/{id}", [
"uses" => "FurnitureController@get",
"as" => "app.furniture.get"
]);
});
});