【问题标题】:Laravel nested controller with restful带有restful的Laravel嵌套控制器
【发布时间】:2012-11-30 08:16:11
【问题描述】:

在我的 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怎么了

【问题讨论】:

  • 您是否为您的服务器设置了适当的重写规则?
  • 是的.. 网站运行良好.. 但我无法进入分类页面

标签: laravel php


【解决方案1】:
Route::get('products/categories', array('as' => 'categories', 'uses' => 'products.categories@index'));

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

【讨论】:

    猜你喜欢
    • 2016-05-13
    • 2013-01-18
    • 2019-12-12
    • 1970-01-01
    • 2015-10-05
    • 1970-01-01
    • 2013-05-25
    • 2017-02-12
    相关资源
    最近更新 更多