Reputation: 6099
I have the following Route::group
setup in my routes.php
file. The problem is that I now want to add a new route Route::post('/timesheets/new', 'Timesheet\TimesheetController@create');
but the problem is the controller is located in a different directory and therefore, the namespace on the group is causing Laravel to look for the controller in the same directory.
My Route::group
Route::group(['middleware' => 'admin', 'prefix' => 'admin', 'namespace' => 'Admin'], function ()
{
Route::get('/', 'DashboardController@index');
Route::get('/contractors', 'ContractorController@index');
});
I want to add this:
Route::get('/timesheets/new', 'Timesheet\TimesheetController@index');
However, when I do this, I get the error:
Class App\Http\Controllers\Admin\Timesheet\TimesheetController does not exist
Upvotes: 0
Views: 1748
Reputation: 13562
This should work:
Route::group(['middleware' => 'admin', 'prefix' => 'admin', ], function ()
{
Route::group(['namespace' => 'Admin'], function() {
Route::get('/', 'DashboardController@index');
Route::get('/contractors', 'ContractorController@index');
});
Route::get('/timesheets/new', 'Timesheet\TimesheetController@index');
});
Upvotes: 2