public function actionGetDatosExamen($reservaId) { // find the zip code from the locations table $reserva = Reserva::findOne($reservaId); $hora = Hora::findOne($reserva->hora_medica_id); $exSolicitados = HoraExamenSolicitado::find()->where(['hora_id' => $hora->id])->all(); foreach ($exSolicitados as $i => $exSolicitado) { $examen = Examen::findOne($exSolicitado->examen_id); $examenes[$i] = $examen; } echo Json::encode($examenes); }
/** * Finds the Hora model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Hora the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Hora::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }