执行以下代码时出现<404>错误。 Class'MagazineModel'将控制器扩展为类'杂志'。 Qestion是:我可以在Class'Magazine'中创建'MagazineModel'的对象吗?
如果我不能,我怎么能以不同的方式做到这一点?谢谢你的帮助!
Class Magazine extends Controller
{
public $id;
public $name;
public $logo_path;
public $order;
public $description;
//model instance container
public $magazine_model;
public function __construct()
{
parent::__construct();
//properties from model
if (class_exists('MagazineModel')) {
$this->magazine_model = new MagazineModel();
}
}
public function getId()
{
return $this->id;
}
public function getName()
{
return $this->name;
}
public function getLogoPath()
{
return $this->logo_path;
}
public function getOrder()
{
return $this->order;
}
public function getDescription()
{
return $this->description;
}
public function testShow()
{
echo $this->twig->render('index.html.twig');
}
}