简体   繁体   中英

Laravel nested controller with restful

In my Laravel Project, I have following folder structures

application/controllers/products.php

application/controllers/products/categories.php

In my 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);
    }    
}

in my 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);
    }    
}

this is my routes.php

Route::get('products', array('as' => 'products', 'uses' => 'products@index'));
Route::get('products/categories', array('as' => 'categories', 'uses' => 'categories@index'));

When I browse the example.com/products/categories , I've got 404 error message. Whats wrong with my routes.php

Route::get('products/categories', array('as' => 'categories', 'uses' => 'products.categories@index'));

注意'uses' => 'products.categories@index'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM