[英]Routing with multiple parameters in laravel
我想在网址中使用两种方法:
如果只有第一个URL的内容,我想使用SectionController,如果有第二个URL的内容,我想使用FurnitureController。 现在,如果我仅在网址中添加/ en / section / 1,则会出现此错误:
缺少[Route: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"
]);
});
});
您可以在组中使用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"
]);
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.