Class laravel 条路线不存在
Class does not exist for laravel routes
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
不是 class,然而:App\Http\Controllers\Api\V1\Investments\InvestmentTransactionsController
是并且 getTransactionsForOffering
是一个动作。
怎么回事?
我相信你只需要像这样引用 Class:
Route::controller('investment-transactions','InvestmentTransactionsController@Index'); //make sure you create a function for the index
Route::controller('investment-transactions/{offeringID}', 'InvestmentTransactionsController@getTransactionsForOffering');
假设您需要显示路线的视图 investment-transactions
在您的控制器中创建以下函数:
public function index()
{
return view('name-of-your-view-file');
}
我相信你的问题出在routes.php我们可以按如下方式使用控制器
Route::get('investment-transactions', 'InvestmentTransactionsController@index');
Route::get('investment-transactions/{offeringID}', 'InvestmentTransactionsController@getTransactionsForOffering');
默认情况下,我们的控制器存储在 App/http/controllers 文件夹中 laravel 知道。
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
不是 class,然而:App\Http\Controllers\Api\V1\Investments\InvestmentTransactionsController
是并且 getTransactionsForOffering
是一个动作。
怎么回事?
我相信你只需要像这样引用 Class:
Route::controller('investment-transactions','InvestmentTransactionsController@Index'); //make sure you create a function for the index
Route::controller('investment-transactions/{offeringID}', 'InvestmentTransactionsController@getTransactionsForOffering');
假设您需要显示路线的视图 investment-transactions
在您的控制器中创建以下函数:
public function index()
{
return view('name-of-your-view-file');
}
我相信你的问题出在routes.php我们可以按如下方式使用控制器
Route::get('investment-transactions', 'InvestmentTransactionsController@index');
Route::get('investment-transactions/{offeringID}', 'InvestmentTransactionsController@getTransactionsForOffering');
默认情况下,我们的控制器存储在 App/http/controllers 文件夹中 laravel 知道。