KKK
KKK

Reputation: 1662

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

Upvotes: 2

Views: 1231

Answers (1)

TLGreg
TLGreg

Reputation: 8449

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

Note the 'uses' => 'products.categories@index'

Upvotes: 6

Related Questions