【发布时间】:2014-03-22 01:13:23
【问题描述】:
所以我不知道这是否是因为我的项目是命名空间的,但这就是我的路线:
Route::controller( 'videos/{type?}/{id?}', '\App\Controllers\VideoController@getIndex');
Route::get( 'videos', '\App\Controllers\VideoController' );
/** Home/Fallback Controller **/
Route::controller('/', '\App\Controllers\HomeController');
这是我要去的网址:
mysite.com/videos/supplier/1
这是我的视频控制器:
<?php
namespace App\Controllers;
use \View;
use \Asset;
use \App\Models\Video;
class VideoController extends BaseController {
public function getIndex($filterType = null, $filterId = null)
{
Asset::addStyle('css/magnific-popup.css');
Asset::addScript('js/magnific-popup.js');
Asset::addScript('js/magnific-video.js');
$video = new Video();
$this->data['videoCategories'] = $video->getCategories();
$this->data['videoSuppliers'] = $video->getSuppliers();
if( $filterType == 'category' )
{
// grab videos by category id
$this->data['videos'] = $video->getByCategory( $filterId );
}
elseif( $filterType == 'supplier' )
{
// grab videos by supplier id
$this->data['videos'] = $video->getByCategory( $filterId );
}
else
{
// get all videos
$this->data['videos'] = $video->getAll();
}
$this->data['currentId'] = $filterId;
$this->data['currentType'] = $filterType;
$this->layout->content = View::make('videos.index', $this->data);
}
}
当我访问 mysite.com/videos 时,getIndex 方法工作正常...但是当参数开始起作用时,它不会找到其他路线。我认为它试图找到一个嵌套控制器,如 Controllers/Video/CategoryController@getIndex 或其他东西。 这是它给我的错误:
类\App\Controllers\VideoController@getIndex 不存在
感谢您的帮助!
【问题讨论】:
标签: routing namespaces laravel-4