/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = CmbisKpi::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(['kpi_id' => $this->kpi_id, 'kpi_percent_target' => $this->kpi_percent_target, 'kpi_group' => $this->kpi_group]); $query->andFilterWhere(['like', 'kpi_name', $this->kpi_name])->andFilterWhere(['like', 'kpi_b_year', $this->kpi_b_year])->andFilterWhere(['like', 'kpi_function', $this->kpi_function])->andFilterWhere(['like', 'kpi_desc', $this->kpi_desc]); return $dataProvider; }
/** * Finds the CmbisKpi model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $kpi_id * @param string $kpi_b_year * @return CmbisKpi the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($kpi_id, $kpi_b_year) { if (($model = CmbisKpi::findOne(['kpi_id' => $kpi_id, 'kpi_b_year' => $kpi_b_year])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function getKpitable() { return $this->hasOne(CmbisKpi::className(), ['kpi_id' => 'kpi_id']); }