Answer the question
In order to leave comments, you need to log in
Can't print array from table in Yii. Can't see Ccategory model. How to fix?
There was a problem. I'll attach the error to the picture. In the models folder, I created a Category class that describes the relationship between a category and a product. Next, I created a components folder in which I created the menuwidget class with which I want to print the entire array of the category table. Here is the code:
<?php
namespace app\components;
use yii\base\Widget;
use app\models\Category;
class MenuWidget extends Widget {
public $tpl;
public $data;
public $tree;
public $menuHtml;
public function init() {
parent::init();
if ($this->tpl === null) {
$this->tpl = "menu";
}
$this->tpl .='.php';
}
public function run() {
$this->data = Category::find()->all();
debug($this->data);
return $this->tpl;
}
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question