コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
 public function getPlaceCategories()
 {
     return $this->hasMany(CategoryGoogle::className(), ['id', 'categoria_id'])->viaTable(PlaceCategory::className(), ['categoria_id' => 'id']);
 }
コード例 #3
0
ファイル: _form.php プロジェクト: pachopascolat/turismoYii
            <?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']);
?>
コード例 #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPlaces()
 {
     $this->hasMany(CategoryGoogle::className(), ['id' => 'categoria_id'])->viaTable('place_category', ['categoria_id' => 'id']);
 }
コード例 #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCategoria()
 {
     return $this->hasOne(CategoryGoogle::className(), ['id' => 'categoria_id']);
 }
コード例 #6
0
ファイル: Place.php プロジェクト: pachopascolat/turismoYii
 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;
 }
コード例 #7
0
 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);
 }
コード例 #8
0
 /**
  * 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.');
     }
 }
コード例 #9
0
ファイル: Category.php プロジェクト: pachopascolat/turismoYii
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCategoryGoogles()
 {
     return $this->hasMany(CategoryGoogle::className(), ['parent_id' => 'id_categoria']);
 }