Reputation: 12923
Laravel 5.1
This seems strange to me:
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');
});
Seems pretty normal to me, the controller:
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;
}
}
Ok so the action and the controller do exit, but when I run: php artisan routes:list
I get:
[ReflectionException]
Class App\Http\Controllers\Api\V1\Investments\InvestmentTransactionsController@getTransactionsForOffering does not exist
Well obviously App\Http\Controllers\Api\V1\Investments\InvestmentTransactionsController@getTransactionsForOffering
is not a class, how ever: App\Http\Controllers\Api\V1\Investments\InvestmentTransactionsController
is and getTransactionsForOffering
is an action.
Whats going on?
Upvotes: 1
Views: 2339
Reputation: 866
I believe your problem is in the routes.php we can use controllers as follows
Route::get('investment-transactions', 'InvestmentTransactionsController@index');
Route::get('investment-transactions/{offeringID}', 'InvestmentTransactionsController@getTransactionsForOffering');
By default, our controllers are stored in App/http/controllers folder and laravel know it.
Upvotes: 1
Reputation: 787
I believe you only need to reference the Class like so:
Route::controller('investment-transactions','InvestmentTransactionsController@Index'); //make sure you create a function for the index
Route::controller('investment-transactions/{offeringID}', 'InvestmentTransactionsController@getTransactionsForOffering');
Assuming you need to show a view for the route investment-transactions
create the following function in your controller:
public function index()
{
return view('name-of-your-view-file');
}
Upvotes: 0