/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Variabel::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, 'id_topik' => $this->id_topik]); $query->andFilterWhere(['like', 'nama', $this->nama])->andFilterWhere(['like', 'keterangan', $this->keterangan])->andFilterWhere(['like', 'satuan', $this->satuan]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getIdVariabel() { return $this->hasOne(Variabel::className(), ['id' => 'id_variabel']); }
<?php use yii\helpers\Html; use yii\grid\GridView; /* @var $this yii\web\View */ /* @var $searchModel backend\models\FaktaSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Faktas'; $this->params['breadcrumbs'][] = $this->title; $wilayah = \yii\helpers\ArrayHelper::map(\common\models\Wilayah::find()->all(), 'id', 'nama'); $bulan = \yii\helpers\ArrayHelper::map(\common\models\Bulan::find()->all(), 'id', 'nama'); $variabel = \yii\helpers\ArrayHelper::map(\common\models\Variabel::find()->all(), 'id', 'nama'); $kategori = \yii\helpers\ArrayHelper::map(\common\models\Kategori::find()->all(), 'id', 'nama'); $sumberData = \yii\helpers\ArrayHelper::map(\common\models\SumberData::find()->all(), 'id', 'nama_cs'); ?> <div class="fakta-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Create Fakta', ['create'], ['class' => 'btn btn-success']); ?> </p>
/** * @return \yii\db\ActiveQuery */ public function getVariabels() { return $this->hasMany(Variabel::className(), ['id_topik' => 'id']); }
/** * Finds the Variabel model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Variabel the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Variabel::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }