public function search($params)
 {
     $query = ProductCat::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id]);
     $query->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }
 /**
  * Страница категории
  */
 public function actionCat($id)
 {
     $query = Product::find()->joinWith('type')->where([ProductType::TableName() . '.cat_id' => $id]);
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 20]);
     $productList = $query->offset($pages->offset)->limit($pages->limit)->with(['type'])->with(['organization'])->asArray()->all();
     Product::format($productList);
     $randProduct = Product::getRandom(1);
     $randOrg = Organization::getRandom(1);
     $randSpec = Specialist::getRandom(1, [], ['specTypes']);
     return $this->render('cat', ['item' => ProductCat::find()->where(['id' => $id])->asArray()->one(), 'productList' => $productList, 'productPages' => $pages, 'randProduct' => $randProduct, 'randOrg' => $randOrg, 'randSpec' => $randSpec]);
 }
<?php

use yii\helpers\ArrayHelper;
use common\models\Specialist;
use common\models\SpecialistType;
use common\models\Product;
use common\models\ProductType;
use common\models\ProductCat;
use common\models\Diagnos;
use common\models\Organization;
use kartik\widgets\ActiveForm;
use kartik\builder\Form;
//Заболевания диагноз parent_id > 0
$catList = ArrayHelper::index(ProductCat::find()->where(['>', 'parent_id', 0])->asArray()->all(), 'id');
//Список организаций
$orgList = ArrayHelper::index(Organization::find()->asArray()->all(), 'id');
$specList = ArrayHelper::index(Specialist::find()->asArray()->all(), 'id');
$specTypeList = ArrayHelper::index(SpecialistType::find()->asArray()->all(), 'id');
$diagnosList = ArrayHelper::index(Diagnos::find()->asArray()->all(), 'id');
$css = <<<CSS

select.search_select {
  border: 0 none;
  width: 100%; border-bottom: 1px solid #A52024;
  border-left: 1px solid #A52024;
  padding: 3px 10px;
}

.select2-container--krajee .select2-selection {
    -webkit-box-shadow: none;
    box-shadow: none;
示例#4
0
    ?>
">
                  Профиль
              </a>

            <?php 
}
?>

      		  </div>
          </div>
      </header>

     <!-- main-menu -->
        <?php 
$headMenu = ProductCat::loadMenu();
?>

        <section class="block main-menu">
          <div class="block-container">
            <ul>
              <?php 
foreach ($headMenu as $id => $item) {
    ?>
              <li id="<?php 
    echo $item['data']['id'];
    ?>
">

                  <a href="#"><?php 
    echo $item['data']['title'];
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCat()
 {
     return $this->hasOne(ProductCat::className(), ['id' => 'cat_id']);
 }
 /**
  * Finds the ProductCat model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ProductCat the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ProductCat::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProductCats()
 {
     return $this->hasMany(ProductCat::className(), ['parent_id' => 'id']);
 }