/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Failures::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([ 'fail_id' => $this->fail_id, 'fail_units' => $this->fail_units, 'fail_scholar_id' => $this->fail_scholar_id, 'fail_school_id' => $this->fail_school_id, ]); $query->andFilterWhere(['like', 'fail_subject', $this->fail_subject]) ->andFilterWhere(['like', 'failures_scholar_lastName', $this->failures_scholar_lastName]) ->andFilterWhere(['like', 'failures_scholar_firstName', $this->failures_scholar_firstName]) ->andFilterWhere(['like', 'failures_scholar_middleName', $this->failures_scholar_middleName]); return $dataProvider; }
/** * Finds the Failures model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Failures the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Failures::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getFailures() { return $this->hasMany(Failures::className(), ['fail_scholar_id' => 'scholar_id']); }