I was trying to order my controllers in Laravel 4 and adding them some nice namespaces
So i wanted routes like this admin/scholar-groups And i wanted the controller to be in a subfolder called 'admin'
So I have a route file like this:
//Admin Routes
Route::group(array('namespace' => 'admin'), function()
{
Route::group(array('prefix' => 'admin'), function()
{
# Scholar Groups Controller
Route::group(['before' => 'auth|adminGroup'], function()
{
Route::resource('scholar-groups', 'ScholarGroupController');
});
});
});
Then I added a namespace to my scholarGroupController which is in a subfolder named 'admin'
<?php namespace admin;
class ScholarGroupController extends \BaseController {
/**
* Display a listing of the resource.
* GET /scholargroup
*
* @return Response
*/
public function index()
{
$scholarGroups = ScholarGroup::paginate(10);
return View::make('scholar_groups.index',compact('scholarGroups'));
}
But whenever I try to access to my index action in Controller I get this error.
Class 'admin\ScholarGroup' not found
So the namespaces is affecting my model namespace in the following line
$scholarGroups = ScholarGroup::paginate(10);
How do I avoid the namespace affecting this model class namespace?