i have this function
public function getMenu() {
$data2 = [];
$menu = Menu::find()->all();
foreach ($menu as $models) {
$row = [];
$row['label'] = $models->title;
$row['url'] = [$models->route];
if (count($this->getMenu2(' =' . $models->id)) > 0) {
$row['items'] = $this->getMenu2(' =' . $models->id);
}
$data2[] = $row;
}
return $data2;
}
public function getMenu2() {
$data2 = array();
$menu = Menu::find()->all();
foreach ($menu as $models) {
$row = [];
$row['label'] = $models->title;
$row['url'] = [$models->route];
if (count($this->getMenu2(' =' . $models->id)) > 0)
$row['items'] = $this->getMenu2(' =' . $models->id);
$data2[] = $row;
}
return $data2;
}
main.php
<?php
NavBar::begin([
'brandLabel' => '',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar container navbar-inverse',
],
]);
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-left'],
'items' => Menu::getMenu(),
]);
NavBar::end();
?>
i got this error :
Unknown Method – yii\base\UnknownMethodException
Calling unknown method: yii\web\View::getMenu2()
Need help master.