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]);
 }
Ejemplo n.º 3
0
<?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;