/** * Finds the Report model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Report the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { $model = Report::find()->where(['id' => $id, 'patient_id' => Yii::$app->session->get('patient_id')])->one(); if ($model) { return $model; } else { throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.')); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Report::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, 'patient_id' => $this->patient_id, 'operator_id' => $this->operator_id, 'date' => $this->date]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getReport() { return $this->hasOne(Report::className(), ['id' => 'report_id']); }
/** * @return \yii\db\ActiveQuery */ public function getReports() { return $this->hasMany(Report::className(), ['patient_id' => 'id']); }
/** * Finds the Report model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Report the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Report::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.')); } }
/** * @return \yii\db\ActiveQuery */ public function getReports() { return $this->hasMany(Report::className(), ['operator_id' => 'id']); }