【发布时间】:2015-12-22 07:13:32
【问题描述】:
Laravel 5.1
这对我来说似乎很奇怪:
Route::group([
'middleware'=>['auth','acl:view activity dashboard'],
'prefix' => 'api/v1'
], function(){
Route::controller('investment-transactions', 'Api\V1\Investments\InvestmentTransactionsController');
Route::controller('investment-transactions/{offeringID}', 'Api\V1\Investments\InvestmentTransactionsController@getTransactionsForOffering');
});
对我来说似乎很正常,控制器:
namespace App\Http\Controllers\Api\V1\Investments;
use App\Brewster\Models\Company;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class InvestmentTransactionsController extends Controller {
public function __construct() {
}
public function getIndex() {
echo 'Here';
}
public function getTransactionsForOffering($offeringID) {
echo $offeringID;
}
}
好的,所以动作和控制器确实退出了,但是当我运行时:php artisan routes:list 我得到:
[ReflectionException]
Class App\Http\Controllers\Api\V1\Investments\InvestmentTransactionsController@getTransactionsForOffering does not exist
很明显App\Http\Controllers\Api\V1\Investments\InvestmentTransactionsController@getTransactionsForOffering 不是一个类,但是:App\Http\Controllers\Api\V1\Investments\InvestmentTransactionsController 是,getTransactionsForOffering 是一个动作。
发生了什么事?
【问题讨论】:
-
试试
Route::controller('investment-transactions', 'InvestmentTransactionsController@Index'); Route::controller('investment-transactions/{offeringID}', 'InvestmentTransactionsController@getTransactionsForOffering'); -
你的自定义控制器的路径是什么?
标签: php routing laravel-routing laravel-5.1