我使用Laravel 5.6创建项目。
我创建了这个网址:
localhost:8000:/admin/products
(产品,索引页)
路线:
$this->namespace('Products')->group(function () {
$this->resource('products', 'IndexController');
});
我需要创建这个网址:
localhost:8000:/admin/products/type
(产品类型,索引页)
路线:
$this->namespace('Products')->group(function () {
$this->resource('products', 'IndexController');
$this->name('products.')->group(function () {
$this->resource('type', 'ProductTypeController');
});
});
但在Url中是:localhost:8000:/admin/type
!
如何创建此网址? localhost:8000:/admin/products/type
答案 0 :(得分:0)
如果您只想访问'/ admin / products / type',只需使用
Route::get('/admin/products/type', function(){
return 'Hi';
});
如果您想为/../../type url创建资源控制器,只需使用
即可Route::resource('/admin/products/type', 'TypeController')}
它将根据网址重定向到特定的控制器方法。有关更多信息。 Routing in Laravel和Controller