路由重定向到错误视图


Route redirecting to wrong view

我被卡住了,不知道我哪里出错了。

我已经为/barcodes和barcodeController创建了一些方法的路由。

当我点击/barcode路由时,它似乎会进入一个404页面,而不是返回一些文本。

有人知道为什么会这样吗?从逻辑上讲,这应该行得通?

下面是代码....

routes.php -

Route::group(array('prefix' => 'barcodes'), function()
{
   Route::any('/', array('as' => 'barcodes.home', 'uses' => 'BarcodesController@home'));
   Route::any('/{page?}/{seg1?}/{seg2?}', array('uses' => 'BarcodesController@index'));
}); 

BarcodesController.php

class BarcodesController extends FrontEndController {
public function __construct()
{
  Parent::__construct();
  new ContentController;
}

public function index($page = null, $sub_page = null, $id = null)
{
  $keepPage = '/'.$page;
  $page = str_replace('-', '_', $page);
  $sub_page = str_replace('-', '_', $sub_page);
  if (method_exists($this, $page))
{
  return $this->$page($sub_page, $id);
}
else if (SitesPages::pageExists($keepPage))
{
  return View::make('sites.default.page');
}
else
{
  return View::make('errors.404');
}
}

public function home()
{
   if ('Reuest::segment(3) == "")
    {
      return "barcodes";
    }
     else{
       return "sitesbarcodes";
    }
 }
 public function howto()
 {
     return View::make('sites.barcodes.howto');
  }
}

您的路由'/barcode'似乎正在进入/{page?}/{seg1?}路由,但是它不能找到方法'barcodes'根据你的路由定义。