I have this main controller:
namespace App\Core;
/**
* Controller class
*/
class Controller
{
/** @var View View The view object */
public $View;
public $templates;
/**
* Construct the (base) controller. This happens when a real controller is constructed, like in
*/
public function __construct()
{
}
public function loadModel($name) {
$path = '\\App\\Front\\Model\\'.$name; // Not Work
//$this->model = new \App\Front\Model\IndexModel(); Work
$this->model = new $path;
return $this->model;
}
}
In IndexController I have:
namespace App\Front\Controller;
use App\Front\Model\IndexModel;
class IndexController extends \App\Core\Controller {
public function index(){
$this->loadModel('IndexModel()')->test();
}
}
Now in action I see error:
Fatal error: Uncaught Error: Class '\App\Front\Model\IndexModel()' not found in /Applications/MAMP/htdocs/mvc/application/Core/Controller.php:64
how do fix error?