public function getParent() { return $this->hasOne(Bar::className(), ['id' => 'parentBar']); }
// foreach($list as $k=>$v){ // if(!$k){ // continue; // } // echo '<dl>'; // echo '<dt>'.$k.'</dt>'; // foreach($v as $kk=>$vv){ // echo '<dd><a href="'.$vv['link'].'">'.$vv['name'].'</a></dd>'; // } // echo '</dl>'; // // } $parent = Bar::find()->where(['isTop' => 0])->orderBy('sort ASC')->all(); $list = []; foreach ($parent as $k => $v) { $m = Bar::find()->where(['parentBar' => $v->id])->orderBy('sort ASC')->all(); echo '<dl>'; echo '<dt>' . $v->name . '</dt>'; foreach ($m as $kk => $vv) { echo '<dd><a href="' . $vv->link . '">' . $vv['name'] . '</a></dd>'; } echo '</dl>'; } ?> </div> <div class="ly-rt"> <div class="search_wp"> <form action="#" method="post"> <input class="transition" type="text" value="" /> <button class="btn" type="submit"></button> <div class="iconfont"></div>