在我的Laravel项目中,我有以下文件夹结构
application/controllers/products.php
application/controllers/products/categories.php
在我的products.php
class Products_Controller extends Base_Controller {
public $restful = true;
public function get_index()
{
$data['title'] = 'Products List';
return View::make('product.index',$data);
}
}
在categories.php
class Products_Categories_Controller extends Base_Controller{
public $restful = true;
public function get_index(){
$data['title'] = "All Categtories";
return View::make('category.index', $data);
}
}
这是我的routes.php
Route::get('products', array('as' => 'products', 'uses' => 'products@index'));
Route::get('products/categories', array('as' => 'categories', 'uses' => 'categories@index'));
当我浏览example.com/products/categories
时,我收到了404错误消息。我的routes.php
答案 0 :(得分:6)
Route::get('products/categories', array('as' => 'categories', 'uses' => 'products.categories@index'));
请注意'uses' => 'products.categories@index'