/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Patient::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->joinWith('patientDoctor'); $query->joinWith('patientRoom'); $query->andFilterWhere(['patient_id' => $this->patient_id, 'patient_birthday' => $this->patient_birthday, 'patient_ceckin' => $this->patient_ceckin]); $query->andFilterWhere(['like', 'patient_name', $this->patient_name])->andFilterWhere(['like', 'patient_gender', $this->patient_gender])->andFilterWhere(['like', 'patient_address', $this->patient_address])->andFilterWhere(['like', 'patient_phone', $this->patient_phone])->andFilterWhere(['like', 'patient_email', $this->patient_email])->andFilterWhere(['like', 'patient_status', $this->patient_status])->andFilterWhere(['like', 'room.room_name', $this->patient_room])->andFilterWhere(['like', 'doctor.doctor_name', $this->patient_doctor]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getPatients() { return $this->hasMany(Patient::className(), ['patient_doctor' => 'doctor_id']); }
/** * @return \yii\db\ActiveQuery */ public function getPatients() { return $this->hasMany(Patient::className(), ['patient_room' => 'room_id']); }
/** * Finds the Patient model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Patient the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Patient::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }