/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = CategoryGoogle::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->joinWith('parent'); $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'category.nombre_categoria', $this->categoryName]); return $dataProvider; }
public function getPlaceCategories() { return $this->hasMany(CategoryGoogle::className(), ['id', 'categoria_id'])->viaTable(PlaceCategory::className(), ['categoria_id' => 'id']); }
<?php $items = yii\helpers\ArrayHelper::map(\app\models\Category::find()->all(), 'id_categoria', 'nombre_categoria'); echo Html::label('Categorias'); echo Html::dropDownList('lista-categorias', '', $items, ['class' => 'form-control', 'prompt' => 'Elija una categoria Superior', 'onchange' => 'cambiarChecklist($(this).val())']); ?> </div> </div> <?php \yii\widgets\Pjax::begin(); ?> <?php $items = yii\helpers\ArrayHelper::map(\app\models\CategoryGoogle::find()->all(), 'id', 'nombre'); $model->categoryGoogles = yii\helpers\ArrayHelper::getColumn($model->getCategoryGoogles(), 'id'); echo $form->field($model, 'categoryGoogles')->checkboxList($items, ['class' => '']); ?> <?php \yii\widgets\Pjax::end(); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?>
/** * @return \yii\db\ActiveQuery */ public function getPlaces() { $this->hasMany(CategoryGoogle::className(), ['id' => 'categoria_id'])->viaTable('place_category', ['categoria_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getCategoria() { return $this->hasOne(CategoryGoogle::className(), ['id' => 'categoria_id']); }
public function getCategoryGoogleStr() { $strCat = ""; $placeCategory = PlaceCategory::findAll(['place_id' => $this->place_id]); foreach ($placeCategory as $mcat) { $strCat = $strCat . " | " . CategoryGoogle::findOne($mcat->categoria_id)->name; } return $strCat; }
public function actionListSubCategory($id) { $model = new Place(); $categorys = \yii\helpers\ArrayHelper::map(\app\models\CategoryGoogle::find()->where(['parent_id' => $id])->orderBy('nombre ASC')->all(), 'id', 'nombre'); echo \yii\helpers\Html::checkboxList("Place[categoryGoogles]", null, $categorys); }
/** * Finds the CategoryGoogle model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return CategoryGoogle the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = CategoryGoogle::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getCategoryGoogles() { return $this->hasMany(CategoryGoogle::className(), ['parent_id' => 'id_categoria']); }