/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = AddressCityType::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 's_name', $this->s_name])->andFilterWhere(['like', 'f_name', $this->f_name]);
     return $dataProvider;
 }
Example #2
0
echo Html::encode($this->title);
?>
</h1>

    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <?php 
echo Html::a(Html::tag('i', '', ['class' => 'glyphicon glyphicon-plus']) . ' ' . Yii::t('app', 'Create City'), ['create'], ['class' => 'btn btn-success']);
?>
                </div>
                <div class="panel-body">
                    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>
                    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['c_name', 'c_type_id' => ['filter' => AddressCityType::getAddressCityTypeOptions(), 'attribute' => 'c_type_id', 'value' => function (AddressCity $data) {
    return $data->getCTypeId();
}], 'is_grp' => ['filter' => AddressCity::getIsGrpOptions(), 'attribute' => 'is_grp', 'value' => function (AddressCity $data) {
    return $data->getIsGrp();
}], 'parent_id' => ['filter' => AddressCity::getParentIdOptions(), 'attribute' => 'parent_id', 'value' => function (AddressCity $data) {
    return $data->getParentId();
}], ['class' => 'yii\\grid\\ActionColumn', 'contentOptions' => ['style' => 'width: 100px; text-align: center;']]]]);
?>
                </div>
            </div>
        </div>
    </div>
</div>
 /**
  * Finds the AddressCityType model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return AddressCityType the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = AddressCityType::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #4
0
 public function getAddressCityType()
 {
     return $this->hasOne(AddressCityType::className(), ['id' => 'c_type_id']);
 }