/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Family::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, 'father_contact' => $this->father_contact, 'father_birthdate' => $this->father_birthdate, 'mother_contact' => $this->mother_contact, 'mother_birthdate' => $this->mother_birthdate, 'guardian_contact' => $this->guardian_contact, 'guardian_birthdate' => $this->guardian_birthdate, 'household_income' => $this->household_income]); $query->andFilterWhere(['like', 'father_name', $this->father_name])->andFilterWhere(['like', 'father_occupation', $this->father_occupation])->andFilterWhere(['like', 'father_company', $this->father_company])->andFilterWhere(['like', 'mother_name', $this->mother_name])->andFilterWhere(['like', 'mother_occupation', $this->mother_occupation])->andFilterWhere(['like', 'mother_company', $this->mother_company])->andFilterWhere(['like', 'guardian_name', $this->guardian_name])->andFilterWhere(['like', 'guardian_occupation', $this->guardian_occupation])->andFilterWhere(['like', 'guardian_company', $this->guardian_company])->andFilterWhere(['like', 'sibling', $this->sibling]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getFamily0() { return $this->hasOne(Family::className(), ['id' => 'family']); }
/** * @return \yii\db\ActiveQuery */ public function getFamilies() { return $this->hasMany(Family::className(), ['sibling' => 'sibling_name']); }
/** * Finds the Family model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Family the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Family::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }