public function auth() { if ($this->validate()) { $patient = Patient::find()->where(['name' => $this->name, 'passcode' => $this->passcode])->one(); if ($patient) { return $patient->id; } } return false; }
/** * 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.'); } }
/** * @return \yii\db\ActiveQuery */ public function getPatient() { return $this->hasOne(\app\models\plrs\Patient::className(), ['id' => 'patient_id']); }
<div class="report-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->errorSummary($model); ?> <?php echo $form->field($model, 'id', ['template' => '{input}'])->textInput(['style' => 'display:none']); ?> <?php echo $form->field($model, 'patient_id')->widget(\kartik\widgets\Select2::classname(), ['data' => \yii\helpers\ArrayHelper::map(\app\models\plrs\Patient::find()->orderBy('id')->asArray()->all(), 'id', 'name'), 'options' => ['placeholder' => Yii::t('app', 'Choose Patient')], 'pluginOptions' => ['allowClear' => true]]); ?> <!-- $form->field($model, 'operator_id')->widget(\kartik\widgets\Select2::classname(), [ 'data' => \yii\helpers\ArrayHelper::map(\app\models\plrs\Operator::find()->orderBy('id')->asArray()->all(), 'id', 'username'), 'options' => ['placeholder' => Yii::t('app', 'Choose Operator')], 'pluginOptions' => [ 'allowClear' => true ], ]) --> <?php echo $form->field($model, 'date')->widget(\kartik\widgets\DatePicker::classname(), ['options' => ['placeholder' => Yii::t('app', 'Choose Date')], 'type' => \kartik\widgets\DatePicker::TYPE_COMPONENT_APPEND, 'pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']]); ?> <div class="form-group" id="add-report-test"></div>